4.4.8 Alignment of Objects

The __align(alignment) specifier can be used to indicate that variables must be aligned on a memory address that is a multiple of the alignment specified. The alignment term must be a power of 2. Positive values request that the object’s start address be aligned.

Example

The following shows variables qualified using __align() to ensure they end on an address that is a multiple of 8, and start on an address that is a multiple of 2, respectively.

__align(-8) int spacer;
__align(2) char coeffs[6];

Differences

An alignment feature has never been implemented on 8-bit compilers.

The 16- and 32-bit compilers used the aligned attribute with variables.

Migration to the CCI

For 16- and 32-bit compilers, change any occurrence of the aligned attribute to __aligned, for example, from:

char __attribute__((aligned(4)))mode;

to:

__align(4) char mode;