The variable attribute aligned allows you to specify a minimum
alignment in bytes for a variable or structure member. Specifying the
alignment can improve the efficiency of copy operations because the compiler
can then use the instructions that copy the largest amounts of memory when
copying to or from the variables or structure members aligned in this
way.
When the aligned variable attribute is applied to an automatic variable, the alignment is limited by the maximum alignment of the stack. When attribute aligned is applied to a bit field structure member, the bit field container is aligned according to the alignment specification, unless the alignment of the container is greater than the alignment factor. In this case, attribute aligned is ignored.
>>-__attribute__------------------------------------------------> >--((--+-aligned-----+--+------------------------+--))--------->< '-__aligned__-' '-(--alignment_factor--)-'
where alignment_factor is a constant expression that evaluates to a positive power of 2.
Omitting the alignment factor (and its enclosing parentheses) allows the compiler to determine an alignment. The alignment will be the largest strict alignment for any natural type (that is, integral or real) that can be handled on the target machine.
The aligned attribute only increases alignment. The packed attribute can be used to decrease it. An alignment factor greater than the platform maximum is ignored with a warning, and the results are unpredictable.
Related References