HP C A.06.05 Reference Manual
Preprocessing Directives
Conditional Compilation (#if, #ifdef, ..#endif)
Chapter 7 195
Conditional Compilation (#if, #ifdef, ..#endif)
Conditional compilation directives allow you to delimit portions of code that are compiled if a
condition is true.
Syntax
conditional-directive
::=
#if
constant-expression newline [group]
#ifdef
identifier newline [group]
#ifndef
identifier newline [group]
#else
newline [group]
#elif
constant-expression newline [group]
#endif
Here,
constant-expression
may also contain the deļ¬ned operator:
defined
identifier
defined (
identifier
)
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 structure of the
conditional compilation directives can be shown using the #if directive:
#if
constant-expression
.
.
.
/* (Code that compiles if the expression evaluates
to a nonzero value.) */
#else
.
.
.
.
/* (Code that compiles if the expression evaluates
to a zero value.) */
#endif