Could we have some kind of keyword to define packed structs in Cython?
This is not part of the C standard, but is supported in most C compilers
through extensions. (Obviously one can do it now through writing a
header file, but that is inconvenient.)

I.e. something like:

cdef packed struct MyStruct:
     char a
     double b

would output conditional code to do either __attribute__((__packed__))
or #pragma pack(push,1), #pragma pack(pop) (gcc/icc and Visual C, 
respectively).

PEP-3118 buffers (like NumPy arrays) can contain arbitrarily packed 
data, and this would help me write readable testing code for that (as 
well as anyone actually using such types, however of course one should 
always align ones data properly...)

BTW, any volunteers for Visual C testing on this? Also, does anyone know 
wheter it is possible to have a #pragma in a #define, like this:

#define SOMEMACRO #pragma pack(push, 1)

?

-- 
Dag Sverre

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to