-qalign

Description

Specifies what aggregate alignment rules the compiler uses for file compilation. Use this option to specify the maximum alignment to be used when mapping a class-type object, either for the whole source program or for specific parts.

Syntax

Read syntax diagramSkip visual syntax diagram                  .-full-------.
>>- -q--align--=--+-power------+-------------------------------><
                  +-natural----+
                  +-mac68k-----+
                  +-twobyte----+
                  +-packed-----+
                  '-bit_packed-'

where available alignment options are:

full The compiler uses the RISC System/6000(R) alignment rules. This is the default.
Note:
The full suboption is the default to ensure backward-compatibility with existing objects. If backward-compatibility is not necessary, you should consider using natural alignment to improve potential application performance.
power The compiler uses the RISC System/6000 alignment rules. The power option is the same as full.
mac68k The compiler uses the Macintosh** alignment rules. This suboption is valid only for 32-bit compilations.
twobyte The compiler uses the Macintosh alignment rules. The twobyte option is the same as mac68k. This suboption is valid only for 32-bit compilations.
packed The compiler uses the packed alignment rules.
bit_packed The compiler uses the bit_packed alignment rules. Alignment rules for bit_packed are the same as that for packed alignment except that bitfield data is packed on a bit-wise basis without respect to byte boundaries.
natural The compiler maps structure members to their natural boundaries. This has the same effect as the power suboption, except that it also applies alignment rules to doubles and long doubles that are not the first member of a structure or union.

Notes

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

You can control the alignment of a subset of your code by using #pragma align=alignment_rule to override the setting of the -qalign compiler option. Use #pragma align=reset to revert to a previous alignment rule. The compiler stacks alignment directives, so you can go back to using the previous alignment directive, without knowing what it is, by specifying the #pragma align=reset directive. For example, you can use this option if you have a class declaration within an include file and you do not want the alignment rule specified for the class to apply to the file in which the class is included.

Examples

Example 1 - Affecting Only Aggregate Definition

Using the compiler invocation:

xlc++ file2.C /* <-- default alignment rule for file is                 */
            /*          full because no alignment rule specified */

Where file2.C has:

extern struct A A1;
typedef struct A A2;

#pragma options align=bit_packed /* <-- use bit_packed alignment rules*/
struct A {
  int a;
  char c;
};
#pragma options align=reset /* <-- Go back to default alignment rules */

struct A A1;  /* <-- aligned using bit_packed alignment rules since   */
A2 A3;        /*     this rule applied when struct A was defined      */

Example 2 - Imbedded #pragmas

Using the compiler invocation:

xlc -qalign=mac68k file.c  /* <-- default alignment rule for file is */
                           /*    Macintosh                           */

Where file.c has:

struct A {
  int a;
  struct B {
    char c;
    double d;
#pragma options align=power      /* <-- B will be unaffected by this  */
                            /*     #pragma, unlike previous behavior; */
                            /*     Macintosh alignment rules still    */
                            /*     in effect                          */
  } BB;
#pragma options align=reset /* <-- A is unaffected by this #pragma;   */
} AA;                       /*     Macintosh alignment rules still    */
                            /*     in effect                          */

Related information