C/C++ Programmer's Guide (G06.25+)

Compiler Pragmas
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
13-29
FIELDALIGN
pragma is combined with the SHARED pragma or CALL_SHARED, and ignores
the GP_OK directive. The TNS/E compiler ignores this directive.
Specifying EXTERN_DATA GP_OK as the global default might prevent some
ISO/ANSI C Standard conforming programs from linking successfully. This might
occur if the user program uses SRL data but does not use the correct header file to
declare the SRL data.
For example, the C run-time library is in an SRL, and all the data it exports (such
as errno) is SRL data. GP-addressing cannot be used to access SRL data. The
nld utility issues an error when an SRL data item is addressed through GP. You
can correct this problem by doing one of the following:
°
Use the default value for EXTERN_DATA, which is NO_GP.
°
Use the correct header file to declare the SRL data.
°
Add a #pragma extern_data no_gp SRL-variable-name for each SRL
data object that the program explicitly declares.
EXTERN_DATA has no effect if the compilation specifies the SRL directive.
Examples
/* “excerpt” from <errno.h> */
#pragma push extern_data
#pragma extern_data no_gp
extern int errno; /* References to errno will not use
GP-relative addressing. */
#pragma pop extern_data
/* alternative form */
extern int errno;
#pragma extern_data no_gp errno
FIELDALIGN
The FIELDALIGN pragma controls the component layout of structures for compatibility
between TNS and native structure layout and for compatibility with native mixed-
language structure layout.
FIELDALIGN align-attribute [ tag-list ]
align-attribute:
{ AUTO | CSHARED2 | SHARED2 | SHARED8 | PLATFORM }
tag-list:
tag-name [ tag-list ]