#pragma align integer(variable [,variable...]) |
Use align to make the listed variables memory-aligned to integer bytes, overriding the default. The following limitations apply:
integer must be a power of 2 between 1 and 128; valid values are 1, 2, 4, 8, 16, 32, 64, and 128.
variable is a global or static variable; it cannot be a local variable or a class member variable.
If the specified alignment is smaller than the default, the default is used.
The pragma line must appear before the declaration of the variables that it mentions; otherwise, it is ignored.
Any variable mentioned on the pragma line but not declared in the code following the pragma line is ignored. Variables in the following example are properly declared.
#pragma align 64 (aninteger, astring, astruct) int aninteger; static char astring[256]; struct S {int a; char *b;} astruct; |
When #pragma align is used inside a namespace, mangled names must be used. For example, in the following code, the #pragma align statement will have no effect. To correct the problem, replace a, b, and c in the #pragma align statement with their mangled names.
namespace foo { #pragma align 8 (a, b, c) static char a; static char b; static char c; } |