Implementation Dependency - Structures, Unions, Enumerations, Bit Fields (A.6.3.9) (F.3.9)

If a union object is accessed using a member of a different type, the result is undefined. (3.3.2.3)

The alignment and padding of structures and unions are subject to the following rules (3.5.2.1):

An unsigned int bit field is equivalent to a plain int bit field. (3.5.2.1)

Bit fields within an int are allocated from low memory to high memory. For example, 0x12345678 is stored with byte 0 containing 0x12, and byte 3 containing 0x78. (3.5.2.1)

The type of an enum bit field is the underlying type of the enumeration.

The maximum bit field length for the compiler is 32 bits. If a series of bit fields does not add up to the size of an int, padding may take place.

Bit fields cannot cross a storage-unit boundary. For example, in the following struct, with bit fields mapped as shown,

struct S {
    unsigned int bit : 30;
    unsigned int bit : 3;
    unsigned int bit : 8;
}

the 3-bit bit field following the 30-bit bit field would cross a 32-bit word-storage boundary. Because crossing a word boundary is not allowed, the 30 bit field is padded and the 3-bit field starts another word.

The -qalign= option allows you to specify different bit-field alignment rules.

Values of an enumeration type are represented by the integral type signed int. (3.5.2.2)

You can use the -qenum=small compiler option to minimize the size of enumerations to 1, 2, or 4 bytes.



Implementation-Defined Behavior
Implementation Dependencies
align Compiler Option
enum Compiler Option