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

Preprocessor Directives and Macros
HP C/C++ Programmer’s Guide for NonStop Servers429301-002
12-16
Preprocessor Operators
The ENV pragma setting determines which of these native mode feature-test macros is
defined:
These feature-test macros cannot be used to ensure that a C run-time library call can
be made in a particular environment. For more information, see the description of
pragma ENV on page 13-19.
Preprocessor Operators
There are two preprocessor operators, # and ##. The # operator allows you to create a
character string literal when the operator precedes a formal parameter in a macro
definition. The ## operator allows you to concatenate two tokens in a macro definition.
Both of these operators are used in the context of the #define directive.
Operator #
The unary operator # is used only with function-like macros, which take arguments. If
the # operator precedes a formal parameter in the macro definition, the actual
argument passed by the macro invocation is enclosed in quotation marks and treated
as a string literal. The string literal then replaces each occurrence of a combination of
the # operator and the formal parameter within the macro definition.
White space preceding the first token of the actual argument and following the last
token of the actual argument is deleted. If a character contained in the argument
normally requires an escape sequence when used in a string literal, for example the
quotation mark (") or backslash (\) characters, the necessary escape backslash is
automatically inserted before the character.
Example
#define str(x) # x
causes the invocation:
str(testing)
_COMMON Identifies code that runs with pragma ENV COMMON set. Pragma ENV
COMMON is the default setting. Such code runs in the user code space
and requires the Common Run-Time Environment (CRE).
_EMBEDDED Identifies code that runs with pragma ENV EMBEDDED set. Such code
runs in the system code space and cannot use the Common Run-
Time Environment (CRE).
_LIBRARY Identifies code that runs with pragma ENV LIBRARY set. Such code
runs in the user library space and requires the Common Run-Time
Environment (CRE).
_LIBSPACE Identifies code that runs with pragma ENV LIBSPACE set. Such code
runs in the user library or system library space and cannot use the
Common Run-Time Environment (CRE).