In Cython glue declarations, how do I represent a C struct type containing an anonymous union? For example, if I have a C header file mystruct.h containing
struct mystruct
{
union {
double da;
uint64_t ia;
};
};
then, in the corresponding .pyd file
cdef extern from "mystruct.h":
struct mystruct:
# what goes here???
I tried this:
cdef extern from "mystruct.h":
struct mystruct:
union {double da; uint64_t ia;};
but that only gave me “Syntax error in C variable declaration” on the union line.
You can’t nest declarations to the best of my knowledge, and Cython doesn’t support anonymous unions AFAIK.
Try the following:
Now access the union members as
un.lower_dandun.lower.