This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ztane
Recipients Charles Machalow, amaury.forgeotdarc, belopolsky, eryksun, meador.inge, ztane
Date 2017-08-30.09:51:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
To Charles first: "Gives back a sizeof of 8 on Windows and 10 on Linux. The inconsistency makes it difficult to have code work cross-platform." 

The bitfields in particular and ctypes in general have *never* been meant to be cross-platform - instead they just must need to match the particular C compiler behaviour of the platform, thus the use of these for cross platform work is ill-advised - perhaps you should just use the struct module instead.

However, that said, on Linux, sizeof these structures - packed or not - do not match the output from GCC; unpacked one has sizeof 12 and packed 10 on my Python 3.5, but they're both 8 bytes on GCC. This is a real bug.

GCC says that the bitfield behaviour is:

Whether a bit-field can straddle a storage-unit boundary (C90, C99 and C11

Determined by ABI.
The order of allocation of bit-fields within a unit (C90, C99 and C11

Determined by ABI.
The alignment of non-bit-field members of structures (C90, C99 and C11

Determined by ABI. 

Thus, the actual behaviour need to be checked from the API documentation of the relevant platform. However - at least for unpacked structs - the x86-64 behaviour is that a bitfield may not cross an addressable unit.
Date User Action Args
2017-08-30 09:51:24ztanesetrecipients: + ztane, amaury.forgeotdarc, belopolsky, meador.inge, eryksun, Charles Machalow
2017-08-30 09:51:23ztanesetmessageid: <>
2017-08-30 09:51:23ztanelinkissue29753 messages
2017-08-30 09:51:23ztanecreate