-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Hi,
I have this problem that I am using CFFI in ABI mode and have a header using MSVC pragma pack convention.
Following is an example struct that results in different size with 64bit Python on Windows depending on whether pack is enabled or not. (36 bytes with packing, 40 bytes without packing)
import cffi
ffi = cffi.FFI()
ffi.cdef("""
typedef enum { FOO, BAR } Test;
typedef struct {
size_t mysize;
Test someenum;
uint64_t x;
uint64_t y;
uint64_t z;
} Foo;""", packed=True)
assert ffi.sizeof("Foo") == 36
what CFFI does is it wipes the pragma pack declaration out completely. I may be able to workaround the issue as per above by using packed=True, however, CFFI functionality of silently generating invalid structs in ABI mode without any warning or error seems scary to me. Ideally it would be great if CFFI handled scoped packing correctly but it seems minimal scope would be at least erroring out if you have packing requested in cdef but packed==False.
Metadata
Metadata
Assignees
Labels
No labels