HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)

Conditional Compilation (#if, #ifdef, .. #endif)
Conditional compilation directives allow you to delimit portions of code that are compiled
only if a condition is true.
Syntax
conditional-directive ::=
#if constant-expression newline
#ifdef identifier newline [group]
#ifndef identifier newline [group]
#else newline [group]
#elif constant-expression newline [group]
#endif
Here, constant-expression may also contain the defined operator:
defined identifier
defined (identifier)
The constant-expression is like other C++ integral constant expressions except
that all arithmetic is carried out in long int precision. Also, the expressions cannot
use the sizeof operator, a cast, an enumeration constant, or a const object.
Description
You can use #if, #ifdef, or #ifndef to mark the beginning of the block of code that
will only be compiled conditionally. An #else directive optionally sets aside an alternative
group of statements. You mark the end of the block using an #endif directive.
The following #if directive illustrates the structure of conditional compilation:
#if constant-expression
...
(Code that compiles if the expression evaluates to a nonzero value.)
...
#else
...
(Code that compiles if the expression evaluates to zero.)
...
#endif
Using the defined Operator
You can use the defined operator in the #if directive to use expressions that evaluate
to 0 or 1 within a preprocessor line. This saves you from using nested preprocessing
directives.
The parentheses around the identifier are optional. Below is an example:
#if defined (MAX) && ! defined (MIN)
...
156 Preprocessing Directives