It would be nice to be able to pack enums in the FFI interface
I'm currently working on communicating with an embedded device (firmware written in C) through Python. I have a post-build script for the firmware which puts all the communication structs/enums/unions into a single header file for cffi to use. Being since this is for communication, everything is __attribute__((packed))
. For struct's isn't an issue since I can filter out the attribute in the script and pass in packed=True
to ffi.cdef
. But, for enums there does not seem to be an equivalent.
I do have a not-so-nice work around which is functioning, but it would be nice to have ffi.cdef
support enum packing, parse the packed attribute, or allow changing the minimum enum size.
Is there a technical reason this isn't already supported? I'm considering looking into adding enum packing support myself, but I'm not sure I'd be able to get the time from work to do it. Thanks.