C/C++ Programmer's Guide (G06.25+)
Compiler Pragmas
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
13-31
FIELDALIGN
While the TNS compilers and the native compilers default to AUTO, the AUTO alignment
rules are not the same for the TNS, TNS/R, and TNS/E native compilers.
Usage Guidelines
•
The FIELDALIGN pragma can be entered on the compiler RUN command line or
in the source text. It can also be specified with the -Wfieldalign flag of the c89
utility.
•
Components whose sizes are different in TNS mode and native mode (_baddr,
_waddr, _near, _sg pointers) are not allowed in CSHARED2, SHARED2, and
SHARED8 structures.
•
Components with AUTO alignment are not allowed in CSHARED2, SHARED2,
PLATFORM, and SHARED8 structures. An error message is issued for invalid
components.
•
The use of pragma FIELDALIGN without a tag-name specifies the default for the
entire compilation. This form of the pragma can be specified on the command line
or at the start of the source text before anything except comments or other
pragmas.
•
Multiple occurrences of a FIELDALIGN pragma without a tag-name within a
compilation is an error.
•
Pragma FIELDALIGN with a tag-name applies only to a struct whose tag-
name is declared in the same scope as the pragma. C has only file (global) and
block (local) scope. C++ has class/struct scope in addition to file and local scopes.
The pragma must occur within the same scope (and before) the struct declaration.
•
Multiple occurrences of a FIELDALIGN pragma for the same tag-name is an error
for TNS compilers but is allowed for native compilers.
•
Use AUTO whenever the data layout is target independent and not shared.
•
Use SHARED2 to share data between TNS programs and native programs.
•
If you use the sizeof() function with a SHARED2 substruct, the actual size
allocated for a struct is returned, including any trailing filler. The size of a SHARED2
substruct that has a tag-name is always a multiple of its alignment. Only
SHARED2 substructs that do not have a tag-name can have an odd-byte size.
•
Use PLATFORM to share data between native C/C++ and pTAL programs that run
on the same platform.
TNS/R native C and C++ compilers FIELDALIGN AUTO FIELDALIGN AUTO
Native c89 utility FIELDALIGN AUTO FIELDALIGN AUTO
TNS/E native C and C++ compilers FIELDALIGN AUTO FIELDALIGN AUTO
SYSTYPE GUARDIAN SYSTYPE OSS