[Python-Dev] ctypes: alignment of (simple) types (original) (raw)
Michael Walle michael at walle.cc
Mon Nov 7 23:37:46 CET 2011
- Previous message: [Python-Dev] [Python-checkins] cpython: quote the type name for improved readability
- Next message: [Python-Dev] ctypes: alignment of (simple) types
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi all,
gcc allows to set alignments for typedefs like:
typedef double MyDouble attribute((aligned(8)));
Now if i use this new type within a structure:
struct s { char c; MyDouble d; };
The following holds: sizeof(struct s) == 16 and offsetof(struct s, d) == 8.
ctypes doesn't seem to support this, although i saw a 'padded' function on the ctypes-users mailinglist which dynamically insert padding fields. I would consider this more or less a hack :)
What do you think about adding a special attribute 'align' which, if set for a data type overrides the hardcoded align property of that type?
-- Michael
- Previous message: [Python-Dev] [Python-checkins] cpython: quote the type name for improved readability
- Next message: [Python-Dev] ctypes: alignment of (simple) types
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]