HP aC++/HP C A.06.25 Programmer's Guide

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)
...
Without using the defined operator, you would have to include the following two
directives to perform the above example:
Overview of the Preprocessor 167