...
Code Block |
---|
struct { unsigned long long a:8; } ull = {255}; |
The following attributes of bit-fields are also implemention defined:
- The alignment of bit fields in the storage unit. For example, the bit fields may be allocated from the high end or the low end of the storage unit.
- Whether or not bit-fields can overlap an storage unit boundary. For example, assuming eight bits to a byte, if bit-fields of six and four bits are declared, is each bitfield contained within a byte or are they be split across multiple bytes?
Resultantly, it is impossible to write portable code that makes assumptions about the layout of bit-fields structures.
References
- ISO/IEC 9899-1999 Section 6.7.2 Type specifiers
- MISRA 04 Rule 3.5