Pyrex - undefined struct/union

François Pinard pinard at iro.umontreal.ca
Sun Apr 13 08:46:31 EDT 2003


[Haris Bogdanovic]

> I have a problem with this piece of code :

> cdef extern from "portaudio.h":
>     struct PaDeviceInfo:
>         int structVersion

[...]

> [...] when compiling C file (generated by pyrexc) I get errors that left
> from all this "info" struct members is an undefined struct/union.  What
> does that mean and how can I fix it ?

When you create declarations within a `cdef extern from "portaudio.h"', you
tell Pyrex about these so it can understand your code, but at the same time,
you ask it to _not_ bother to generate declarations in the C generated code,
on the premise that `#include "portaudio.h" will have done it already.

So, in a word, if C `struct PaDeviceInfo' is declared in "portaudio.h", it
is OK to include the Pyrex `struct Pa PaDeviceInfo' within the `cdef
extern'.  If C `struct PaDeviceInfo' is _not_ declared in "portaudio.h", you
should declare it to Pyrex outside any `cdef extern', and then Pyrex will
forward a C declaration in the C code it generates.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list