[Pyrex] Anonymous union inside struct
Lenard Lindstrom
len-l at telus.net
Mon Jun 9 01:15:50 CEST 2008
Jonne wrote:
> Hi!
>
> I have the following c-code:
>
> typedef struct expansion_t {
> int type;
>
> union {
> struct nunchuk_t nunchuk;
> struct classic_ctrl_t classic;
> struct guitar_hero_3_t gh3;
> };
> } expansion_t;
>
>
> Where all the structures in the union are of a different size.
>
> Now, I know that pyrex can't nest ctypedefs, but is it possible to
> convert this code to pyrex, so
> that I can refer to both exp.type and exp.gh3, if object is an
> expansion_t?
>
>
The structure declaration in an cdef extern never actually declares
anything. It is for Pyrex book keeping only. So unnamed structure or
union elements can be flattened:
cdef extern from "header.h":
struct nunchuk_t:
....
....
ctypedef struct expansion_t:
int type
struct nunchuk_t nunchuk
struct classic_ctrl_t classic
struct guitar_hero_3_t gh3
--
Lenard Lindstrom
<len-l at telus.net>
More information about the Pyrex
mailing list