-qalignrulefor (C++ only)

Category

Portability and migration

Pragma equivalent

None

Purpose

When used with -qalign=power, determines whether a 4-byte alignment ceiling is applied to non-first members of structures that are of type typedef to array of element type that exceeds the alignment ceiling.

Syntax

Read syntax diagramSkip visual syntax diagram
                                   .-typedefrespectsrule---.   
>>- -q--alignrulefor--=--power--=--+-notypedefrespectsrule-+---><

Defaults

-qalignrulefor=power=typedefrespectsrule

Parameters

typedefrespectsrule | notypedefrespectsrule
When typedefrespectsrule is in effect, the member follows the normal alignment rules for -qalign=power. This suboption provides compatibility with code compiled with -qalign=power with XL C++ V6.0 and earlier.

For XL C++ V9.0, the default is typedefrespectsrule.

When notypedefrespectsrule is in effect, a member that exceeds the alignment ceiling of 4 bytes is aligned on 4-byte boundaries. This suboption provides compatibility with code compiled with -qalign=power with XL C++ V7.0 and V8.0.

Predefined macros

None.

Examples

The following example uses a typedef declaration for an array of structures containing a member of long long type, which is not normally subject to a 4-byte alignment ceiling, and then uses the typedef as the non-first member of a structure variable declaration. The table shows the differing alignment results depending on the setting of the -qalignrulefor=power option.

Sample code Alignment results
typedefrespectsrule notypedefrespectsrule

struct A {
    long long a1;
   } a;  

typedef struct A ten_A[10];  

struct B {  
    char dummy[116];
    struct A ten_a[10];
   } b;  

struct C {  
   char dummy[116];    
   ten_A ten_a;
   } c;

alignment of b.ten_a = 8
alignment of b = 8
alignment of c.ten_a = 8  
alignment of c = 8

alignment of b.ten_a = 8
alignment of b = 8
alignment of c.ten_a = 4  
alignment of c = 4

Related information