| |||
| Home > Compiler-specific Features > __align | |||
The __align keyword instructs the compiler
to align a variable on an -byte
boundary.n
__align is a storage class modifier. It
does not affect the type of the function.
__align(n)
Where:
nis the alignment boundary.
For local variables, can
take the values 1, 2, 4, or 8.n
For global variables, can
take any value up to 0x80000000 in powers of 2.n
__align( is
useful when the normal alignment of the variable being declared
is less than n). Eight-byte
alignment can give a significant performance advantage with VFP
instructions.n
__align can be used in conjunction with extern and static.
Because __align is a storage class modifier,
it cannot be used on:
types, including typedefs and structure definitions
function parameters.
You can only overalign. That is, you can make a two-byte object four-byte aligned but you cannot align a four-byte object at 2 bytes.
__align(8) char buffer[128]; // buffer starts on eight-byte boundary
void foo(void)
{
...
__align(16) int i; // this alignment value is not permitted for
// a local variable
...
}
__align(16) int i; // permitted as a global variable.
--min_array_alignment=opt in Using the Compiler.