[Python-Dev] ctypes: alignment of (simple) types

2011年11月07日 14:47:46 -0800

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
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to