Precedence rules for scalar variables

The following formulas use a "top-down" approach to determining the alignment, given the presence of alignment modifiers, for both non-embedded (standalone) scalar variables and embedded scalars (variables declared as members of an aggregate):

Alignment of variable = maximum(effective type alignment , modified alignment value)

where effective type alignment = maximum(maximum(aligned type attribute value, __align specifier value) , minimum(type alignment, packed type attribute value))

and modified alignment value = maximum(aligned variable attribute value, packed variable attribute value)

and where type alignment is the alignment mode currently in effect when the variable is declared, or the alignment value applied to a type in a typedef statement.

In addition, for embedded variables, which can be modified by the #pragma pack directive, the following rule applies:

Alignment of variable = minimum(#pragma pack value , maximum(effective type alignment , modified alignment value))

Note:
If a type attribute and a variable attribute of the same kind are both specified in a declaration, the second attribute is ignored.