Language Implementation
7-11
7
• If the value of the container bit position plus the size in bits of the new
bit field is greater than 32 or if the size of the new bit field is zero, the
compiler inserts padding to align the bit field on the next container
alignment boundary. Bit-field alignment can result in padding of up to
31 bits. If the bit-field size is non-zero and the bit field fits entirely
within the current container, the compiler does not insert padding to
align the bit field.
• For big-endian, the bit position within the container is 31 minus the
above-calculated bit position.
Examples
These examples show how different alignment pragmas alter the
alignment of the components of a structure. The structure is declared as
follows:
struct std_struct
{
unsigned char m1a;
unsigned char m1b;
int m4a;
unsigned short m2a;
unsigned mbit5:5;
unsigned mbit7:7;
unsigned mbit6:6;
double m8a;
};