I am trying to use a C library that uses a callback function (callback_function) to provide a pointer to the structure I would like to wrap (glp_tree).
What is the correct way to initialize an instance with a pointer not created in __cinit__
? I can not find an example of this template in the cython documentation.
I have a working code (see below) in which a pointer to the integer and vice versa, but I'm not sure if this is good practice / normal work.
cdef extern from "stdint.h": ctypedef unsigned long long uint64_t cdef extern from "glpk.h": ctypedef struct glp_tree: pass cdef void callback_func(glp_tree* tree, void *info): treeobj = Tree(<uint64_t>tree)
Passing the glp_tree object directly works (although this is not what I want to do), but trying to pass a pointer results in a compiler error:
Cannot convert 'glp_tree *' to Python object
source share