-qalign
Category
Pragma equivalent
#pragma options align, #pragma align
Purpose
Specifies the alignment of data objects in storage, which avoids performance problems with misaligned data.
Syntax
.-=power------. +-=full-------+ >>- -q--align--+-=bit_packed-+--------------------------------->< +-=mac68k-----+ +-=natural----+ +-=packed-----+ '-=twobyte----'
.-power------. +-full-------+ >>-#--pragma--align--(--+-bit_packed-+--)---------------------->< +-mac68k-----+ +-natural----+ +-packed-----+ +-twobyte----+ '-reset------'
Defaults
-qalign=power
Parameters
- bit_packed | packed
- Bit field data is packed on a bitwise basis without respect to byte boundaries.
- power
- Uses the RISC System/6000 alignment rules. This is the default.
- full
- 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.
- natural
- 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.
Usage
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.
Predefined macros
None.
Examples
/* 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 */
/* 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 /*