Section 2: Compiler
95
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
Each #if directive in a file must be paired with a closing #endif directive. Zero or
more #elif (similar to #else followed by #if) directives can appear between a #if
and #endif pair and at most one #else directive can appear between the pair. If
the #else directive does appear, it must be the last directive before the #endif.
These directives can be nested inside other #if directives.
In the following #if directive sequence,
text block 1 remains in the file if the
constant expression following the #if evaluates to a nonzero value,
text block 2
remains in if the first constant expression evaluates to zero and the constant
expression following the #elif evaluates to nonzero, and
text block 3 remains in if
both constant expressions evaluate to zero:
#if constant_expression
text block 1
#elif constant_expression
text block 2
#else
text block 3
#endif
A constant expression that follows a #if or #elif must contain only integral
constants (including character constants that may contain escape sequences),
and it must not contain the sizeof operator, a cast operator, or an enumeration
constant. However, it may contain unary expressions of either of the following
forms:
defined identifier
defined (identifier)
These evaluate to 1 if the identifier is currently defined as a macro and to 0
otherwise. All identifiers in the constant expression currently defined as macros
(except those that are arguments to the defined operator) are replaced and
identifiers not currently defined are replaced by the constant 0. After all the above
substitutions are performed, the constant expression is evaluated (treating all
constants as 32-bit integers) following the same rules used to evaluate any other
C expression.
Preprocessing directives of the following forms selectively include or exclude the
block of text that follows based on whether the identifier is or is not currently
defined as a macro name:
#ifdef identifier
#ifndef identifier
The above directives are functionally identical to the following:
#if defined (identifier)
#if !defined (identifier)