C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
Compiler Pragmas
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
13-32
FIELDALIGN
°
Templates cannot be specified in FIELDALIGN pragmas and always have
FIELDALIGN AUTO. Nested structs are not implemented for templates.
Templates can contain non-AUTO structs declared using tags.
°
No other pragmas can appear on the same source line as #pragma
FIELDALIGN.
Examples
1. Global pragma FIELDALIGN is allowed anywhere in the source, not just at the
beginning, and it can also be used as an argument to pragmas PUSH and POP.
For example:
#pragma fieldalign auto
// the global fieldalign is now set to auto
struct AutoStruct {};
#pragma push fieldalign
//save the current fieldalign value
#pragma fieldalign shared2
// the global fieldalign is now shared2In t
struct Shared2Struct{};
#pragma pop fieldalign
//global fieldalign is restored to auto
2. In this example, the member str1.str2.c2 starts at a byte address instead of
the typical 16-bit word address:
#pragma fieldalign shared2 STAG
struct STAG { char c1;
struct { char c2;
int i;
} str2; /* substructure declared
inline without tag */
} str1;
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;
...