On the RISC System/6000 system, an aggregate is aligned
according to its most strictly aligned member. Within aggregates,
members are aligned according to their type. The table below
summarizes size and alignment information for each type.
Type, Size, and Alignment for the RISC System/6000 System | ||
Type | Alignment of Member | Size (bytes) |
---|---|---|
char | byte aligned | 1 |
short | halfword aligned | 2 |
(long) int | word aligned | 4 |
long long int | doubleword aligned | 8 |
pointer | word aligned | 4 |
float | word aligned | 4 |
double | doubleword aligned if -qalign=natural. Otherwise, word aligned. | 8 |
long double with -qlongdouble or -qldbl128 option. |
long doubleword aligned if -qalign=natural. Otherwise, word aligned. | 16 |
Notes:
On the RISC System/6000 system, if a double is the first member of a struct, it is 8-byte (doubleword) aligned. If a long double is the first member of a struct, it is 16-byte aligned.
Bit Fields for RISC System/6000 Format
The following rules apply when you are laying out bit fields in structs.
In the C language, you can specify bit fields as char or short instead of int, but the compiler maps them as if they were unsigned int. In extended mode, you can use the sizeof operator on a bit field. (The sizeof operator on a bit field always returns 4.)
align Compiler Option
Macintosh and Twobyte Alignment Rules
Packed Alignment Rules
Alignment Rules for Nested Aggregates