Help Wrapping Multiple Class / Struct functions

14 views
Skip to first unread message

Thomas Gardiner

unread,
Mar 21, 2022, 12:38:02 AM3/21/22
to cython-users

Hi Folks,  

I'm running into a problem that I can't seem to solve.  I have some C-code that I'm trying to wrap that looks something like this.  I have a number of opaque C structs, i.e. in the header file I have

typedef struct A_s A;

and the definition of struct A_s is in the C file.

I have been able to wrap the code using these structs with .pxd and .pyx files, generate the cython code, import them in python and use them.  So far so good...

Now, I have a function that takes a pointer to more than one struct, e.g.

int do_work(A *pa, B *pb, C *pc){...}

and I'm trying to wrap this so that from Python I'm able to have instances of the classes A, B, and C and invoke this function.  This means accessing the pointers to c-structs and I can't see how to do so.  Instead, I keep getting an error message about

do_work.pyx:37:48: Cannot convert Python object to 'const A *'

Any ideas on how I can accomplish this with cython?

Thanks,

Tom Gardiner

Reply all
Reply to author
Forward
0 new messages