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-22
ENV
Usage Guidelines
The ENV pragma is a command-line directive that can be entered on the compiler
RUN command line or be specified in the source text if it is placed before any
declarations. If you are using the c89 utility, you can specify the ENV directive with
the -Wenv flag.
Each ENV option requires certain run-time library and language features. The
Binder restricts you from binding modules with incompatible ENV options. For
more details, see Restrictions on Binding Caused by the ENV Pragma on
page 14-10.
Pragmas ENV EMBEDDED and ENV LIBSPACE restrict the use of C I/O functions.
Guardian I/O functions are allowed.
For TNS C and C++, pragmas ENV LIBRARY and ENV LIBSPACE restrict
relocatable data blocks. Without relocatable data blocks, static data is not allowed.
Therefore, the compiler allocates constants (including character string constants
and data declared with a const type qualifier) in the user code space instead of
the user or system data space. Because the constants are in the user code space,
you cannot pass pointers to these constants between code spaces without using
the CSADDR pragma. For more details, see the pragma CSADDR on page 13-18.
The compiler does not identify the use of restricted C I/O or memory allocation run-
time functions. Use of restricted functions causes a failure when the function is
executed.
The compiler identifies the use of restricted static variables.
For native C and C++, pragmas ENV LIBRARY and ENV LIBSPACE causes the
compiler to place literal constants into the read-only data area. It also causes an
error to be generated for global variable declarations.
Functions in object files listed in SEARCH pragmas retain their original ENV
attributes.
To use C run-time library functions affected by locales and the CHECK pragma
under pragmas ENV EMBEDDED and ENV LIBSPACE, you must specify pragma
NOCHECK and the _IGNORE_LOCALE feature-test macro in the compilation text to
refer to the environmentally neutral variants of the functions.
Main routine Yes No No No
Relocatable data blocks Yes Yes No No
Functions that set errno Yes No Yes No
Table 13-2. ENV Options and the Availability of Run-Time Library and Language
Features (page2of2)
Feature COMMON EMBEDDED LIBRARY LIBSPACE
*ENV LIBRARY permits the use of high-level language I/O facilities if direct access to relocatable
data blocks is not needed for the operations.