[Pyrex] unnamed stucts

Brad Schick schickb at gmail.com
Wed May 7 20:29:48 CEST 2008


Is there a way to declare cdef data structures with nested nameless
structs? Actually I haven't managed to declare any nested structs (named
or unnamed). Is it possible? Seems like this would be a FAQ, but I
haven't yet found the answer.

An example C declaration is below. I believe this is not standard C, but
it is supported by most C compilers (at least all those I've used).

typedef union {
    struct {
        uint32_t lo;
        uint32_t hi;
    };
    struct {
        uint8_t lobytes[4];
        uint8_t hibytes[4];
    };
    uint8_t bytes[8];
} nonce_t;

If I extract the nested stuct declarations and give them names, I assume
the generated C would not compile correctly since it will #include the
original nameless C declaration.

Thanks,
-Brad



More information about the Pyrex mailing list