Pragma equivalent

#pragma options align, #pragma align


Specifies the alignment of data objects in storage, which avoids performance problems with misaligned data.


Read syntax diagramSkip visual syntax diagram
>>- -q--align--+-=bit_packed-+---------------------------------><

Read syntax diagramSkip visual syntax diagram




bit_packed | packed
Bit field data is packed on a bitwise basis without respect to byte boundaries.
Uses the RISC System/6000 alignment rules. This is the default.
Uses the RISC System/6000 alignment rules.
Note: -qalign=full is equivalent to -qalign=power.
mac68k | twobyte
Uses the Macintosh alignment rules. Valid only for 32-bit compilations.
Structure members are mapped to their natural boundaries. This has the same effect as the power suboption, except that it also applies alignment rules to double and long double members that are not the first member of a structure or union.
reset (pragma only)
Discards the current pragma setting and reverts to the setting specified by the previous pragma directive. If no previous pragma was specified, reverts to the command-line or default option setting.


If you use the -qalign option more than once on the command line, the last alignment rule specified applies to the file.

The full suboption is the default to ensure compatibility with existing objects. If compatibility with earlier versions is not necessary, you should consider using natural alignment to improve potential application performance.

The pragma directives override the -qalign compiler option setting for a specified section of program source code. The pragmas affect all aggregate definitions that appear after a given pragma directive; if a pragma is placed inside a nested aggregate, it applies only to the definitions that follow it, not to any containing definitions. Any aggregate variables that are declared use the alignment rule that applied at the point at which the aggregate was defined, regardless of pragmas that precede the declaration of the variables. See below for examples.

Note: When using -qalign, all system headers are also compiled with -qalign. For a complete explanation of the option and pragma parameters, as well as usage considerations, see Aligning data.

Predefined macros



The following examples show the interaction of the option and pragmas. Assuming compilation with the command xlc file2.c, the following example shows how the pragma affects only an aggregate definition, not subsequent declarations of variables of that aggregate type.
/* file2.c  The default alignment rule is in effect */ 

typedef struct A A2;  

#pragma options align=bit_packed /*  bit_packed alignment rules are now in effect */ 
struct A {   
int a;   
char c; 
}; #pragma options align=reset /*  Default alignment rules are in effect again */  

struct A A1;  /*  A1 and A3 are aligned using bit_packed alignment rules since   */ 
A2 A3;        /*  this rule applied when struct A was defined      */
Assuming compilation with the command xlc file.c -qalign=bit_packed, the following example shows how a pragma embedded in a nested aggregate definition affects only the definitions that follow it.
/* file2.c  The default alignment rule in effect is bit_packed  */  
struct A {   
int a;
#pragma options align=power /* Applies to B; A is unaffected  */ 
   struct B {     
   char c;     
   double d;       
            } BB;   /*  BB uses power alignment rules  */ 
} AA;               /*  AA uses bit_packed alignment rules  /*    

Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us