Each data type supported by XL C is aligned along byte boundaries according to platform-specific default alignment modes. On AIX®, the default alignment mode is power or full, which are equivalent.
Each of the valid alignment modes is defined in Table 1, which provides the alignment value, in bytes, for scalar variables, for all data types. Where there are differences between 32-bit and 64-bit modes, these are indicated. Also, where there are differences between the first (scalar) member of an aggregate and subsequent members of the aggregate, these are indicated.
Data type | Storage | Alignment setting | ||||
---|---|---|---|---|---|---|
natural | power, full | mac68k, twobyte3 | bit_packed2 | packed2 | ||
_Bool (32-bit mode) | 1 | 1 | 1 | 1 | 1 | 1 |
_Bool (64-bit mode) | 1 | 1 | 1 | not supported | 1 | 1 |
char, signed char, unsigned char | 1 | 1 | 1 | 1 | 1 | 1 |
wchar_t (32-bit mode) | 2 | 2 | 2 | 2 | 1 | 1 |
wchar_t (64-bit mode) | 4 | 4 | 4 | not supported | 1 | 1 |
int, unsigned int | 4 | 4 | 4 | 2 | 1 | 1 |
short int, unsigned short int | 2 | 2 | 2 | 2 | 1 | 1 |
long int, unsigned long int (32-bit mode) | 4 | 4 | 4 | 2 | 1 | 1 |
long int, unsigned long int (64-bit mode) | 8 | 8 | 8 | not supported | 1 | 1 |
_Decimal32 | 4 | 4 | 4 | 2 | 1 | 1 |
_Decimal64 | 8 | 8 | 8 | 2 | 1 | 1 |
_Decimal128 | 16 | 16 | 16 | 2 | 1 | 1 |
long long | 8 | 8 | 8 | 2 | 1 | 1 |
float | 4 | 4 | 4 | 2 | 1 | 1 |
double | 8 | 8 | see note1 | 2 | 1 | 1 |
long double | 8 | 8 | see note1 | 2 | 1 | 1 |
long double with -qldbl128 | 16 | 16 | see note1 | 2 | 1 | 1 |
pointer (32-bit mode) | 4 | 4 | 4 | 2 | 1 | 1 |
pointer (64-bit mode) | 8 | 8 | 8 | not supported | 1 | 1 |
vector types | 16 | 16 | 16 | 16 | 1 | 1 |
Notes:
|
Alignment of aggregates discusses the rules for the alignment of entire aggregates and provide examples of aggregate layouts. Alignment of bit fields discusses additional rules and considerations for the use and alignment of bit fields, and provides an example of bit-packed alignment.