C/C++ Programmer's Guide (G06.25+)
Preprocessor Directives and Macros
HP C/C++ Programmer’s Guide for NonStop Servers—429301-002
12-13
Feature-Test Macros
D("EDG\n");
/* Expands to "printf("EDG\n", );" -- note the extra comma*/
•
The other variant of variadic macro is the GNU form, provided by the GNU C
compiler. This variant adds to the C9X form the ability to name the variadic
parameter and a special meaning to the token pasting operator ("##"). When the
operator is followed by an empty variadic argument (named or not), the preceding
parameter or continuous sequence of nonwhitespace characters (not part of a
parameter) is erased.
For example:
#define E(fmt, args...) printf (fmt, ## args)
E("%c%s\n", ’E’, "DG");
/* Expands to "printf("%c%s\n", ’E’, "DG");" */
E("EDG\n");
/* Expands to "printf("EDG\n" );" -- no extra comma*/
Feature-Test Macros
The feature-test macros, shown in Table 12-3, determine whether a particular set of
features will be included from header files. Details about these macros follow the table.
Table 12-3. Predefined Feature-Test Macros (page 1 of 2)
Macro What It Defines
_BOOL Defined when bool is a keyword (that is, when using
C++ VERSION2 or VERSION3 dialect)
__CPLUSPLUS Identifiers required to modify C headers for use by
C++. (Note double underscore.) This macro is
automatically defined by the c89 command when
the -Wcplusplus flag is used.
__CPLUSPLUS_VERSION Identifier used by the different versions of native
C++:
•
Has a value of 1 if compiling using the
VERSION1 directive (using D40 features).
•
Has a value of 2 if compiling using the
VERSION2 directive (using D45 features).
•
Has a value of 3 if compiling using the
VERSION3 directive (using G06.20 features).
_GUARDIAN_TARGET Identifiers required for executing in the Guardian
environment
_IEEE_FLOAT Identifiers that support IEEE standard-conforming
binary floating-point arithmetic