C/C++ Programmer's Guide (G06.25+)
Compiler Pragmas
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
13-33
FIELDALIGN
3. In this example, pragma FIELDALIGN SHARED2 causes all structures in the
compilation unit to be the same as TAL’s definition structures, except for any
structure with the tag CTAG, whose members always are 16-bit word-aligned.
#pragma fieldalign shared2
#pragma fieldalign auto CTAG
...
struct CTAG { ...
} cstruct;
...
4. The following example shows the alignment of a structure with bit-field members,
regardless of whether pragma WIDE is present or not:
#pragma fieldalign shared2 ATAG
struct ATAG { char c1;
int b1:3;
int b2:3;
int b3:12;
char c2; } s1;
s1: ----------------------------------
| c1 | filler |
----------------------------------
| <0:2=b1><3:5=b2><6:15=filler> |
----------------------------------
| <0:11=b3><12:15=filler> |
----------------------------------
| c2 | |
----------------------------------
5. The following example shows the alignment of a structure with an array member:
#pragma fieldalign shared2
struct { char c1;
struct { char c2;
int i1;
} a[2];
} s1;
s1: ----------------------------------
| c1 | a[0].c2 |
----------------------------------
|a[0].i1 |
----------------------------------
|filler for a[0] | a[1].c2 |
----------------------------------
|a[1].i1 |
----------------------------------
|filler for a[1] | |
----------------------------------