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

SYSTYPE OSSSYSTYPE GUARDIAN
FIELDALIGN AUTOFIELDALIGN AUTONative c89 and c99 utilities
FIELDALIGN AUTOFIELDALIGN AUTOTNS/E native C and C++ compilers
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 or the c99 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.
SHARED8 requires that you explicitly declare any filler needed to properly align fields. The
compiler issues a warning for improperly aligned fields in a SHARED8 structure.
For more details on structure alignment, see the pTAL Conversion Guide and pTAL Reference
Manual.
If a template class has a non-template base class or a non-template member class with the
FIELDALIGN AUTO attribute, all the instantiations of the template class should have the same
192 Compiler Pragmas