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-28
EXTERN_DATA
GP_OK
means that GP-relative addressing is allowed. This value is not valid for the TNS/E
compilers.
NO_GP
means that GP-relative addressing must not be used. This is the value that
typically indicates that the data is exported by an SRL.
variable-name
identifies a variable that has previously been declared.
The pragma default settings are:
Usage Guidelines
The EXTERN_DATA pragma can be entered on the compiler RUN command line or
in the source text. It can also be specified with the -Wextern_data flag of the
c89 utility.
If no variable-name is given, the pragma sets the global default, which remains
in effect until the next EXTERN_DATA pragma. This form of the pragma can appear
in source code, in the compiler RUN command line, or in a c89 flag.
If a variable-name is given, the pragma sets the addressing type to use for only
the specified variable. This form of the pragma can appear only in the source. It
must occur after the declaration of variable-name.
EXTERN_DATA GP_OK is not compatible with generation of PIC (Position-
Independent Code) code. The TNS/R native compiler issues a warning if this
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 these:
SYSTYPE GUARDIAN SYSTYPE OSS
TNS C compiler N.A. N.A.
G-series TNS c89 utility N.A. N.A.
TNS/R native C and C++ compilers EXTERN_DATA NO_GP EXTERN_DATA NO_GP
Native c89 utility EXTERN_DATA NO_GP EXTERN_DATA NO_GP
TNS/E native C and C++ compilers EXTERN_DATA NO_GP EXTERN_DATA NO_GP