-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                  .-linuxppc---.
>>- -q--align--=--+-bit_packed-+-------------------------------><
 

where available alignment options are:

linuxppc The compiler uses default GNU C/C++ alignment rules to maintain compatibility with GNU C/C++ objects. This is the default.
bit_packed The compiler uses the bit_packed alignment rules. This suboption is similar to the GCC -fpack-struct option.

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                 */
            /*     linuxppc 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=linuxppc file.c  /* <-- default alignment rule for file */
                           /*    is linuxppc                        */

Where file.c has:

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

Related information