Ticket #290 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Support for packed structs

Reported by: dagss Owned by: dagss
Priority: minor Milestone: 0.11.2
Component: Parsing Keywords:
Cc:

Description

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).

Change History

Changed 4 years ago by dagss

It turns out that #pragma pack is supported on GCC >= 3.0. However I can spot at least one instance of Python 2.3 on GCC 2.95 on the internet so I'll include the GCC method as well.

Changed 4 years ago by dagss

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.