Sun Studio 12: C++ User's Guide

B.2.1 #pragma align


#pragma align integer(variable [,variable...])

Use align to make the listed variables memory-aligned to integer bytes, overriding the default. The following limitations apply:


#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;
}