Cython and incomplete type definitions
Aug. 16th, 2013 04:07 pmI've been messing around with an attempt to glue python on to an API layer. I didn't think it'd be all that difficult: I had a couple of pieces of sample code, some reasonably good documentation on the API and the cython manual to hand. But when I tried to convert the API header file into cython definitions, I hit an interesting snag: some of the type definitions I needed to use were incompletely defined.
At first I was thrown by the incomplete definitions, assuming that I'd missed an
It's not a particularly attractive solution to the problem but it seems to work...
At first I was thrown by the incomplete definitions, assuming that I'd missed an
#include somewhere. Once I realised this wasn't the case — I imagine that the structures are only ever defined in a private set of development headers — I tried to work out why the examples worked and why my code failed. Eventually I spotted the pattern: because the incomplete types were only ever used as pointers, their actual contents didn't matter because they were simply being used to reference chunks of memory and, consequently, that all I needed to do to get them working in cython was to define them as void pointers.It's not a particularly attractive solution to the problem but it seems to work...