#IFDEF | #IFNDEF ... #ENDIF Preprocessor Directive
Conditionally
includes a set of commands at compile time if a compile-time constant is
defined.
Syntax
#IFDEF |
#IFNDEF ConstantName Commands [#ELSE Commands] #ENDIF
Arguments
#IFDEF
Specifies that a set of commands is included at compile time when the
ConstantName is defined.
The
following describe how a set of commands is included at compile time when
you include #IFDEF:
- If ConstantName is defined, the set of commands following #IFDEF and
preceding #ELSE or #ENDIF (whichever occurs first) is included at compile
time.
- If ConstantName is not defined and #ELSE is included, the set of commands
following #ELSE and preceding #ENDIF is included at compile time.
- If ConstantName is not defined and #ELSE is not included, no commands
within the #IFDEF ... #ENDIF structure are included at compile time.
#IFNDEF
Specifies that a set of commands is included at compile time when the
ConstantName is not defined.
The
following describe how a set of commands is included at compile time when
you include #IFNDEF:
- If ConstantName is not defined, the set of commands following #IFNDEF and
preceding #ELSE or #ENDIF (whichever occurs first) is included at compile
time.
- If ConstantName is defined and #ELSE is included, the set of commands
following #ELSE and preceding #ENDIF is included at compile time.
- If ConstantName is defined and #ELSE is not included, no commands within
the #IFNDEF ... #ENDIF structure are included at compile time.
ConstantName
Specifies the compile-time constant whose existence determines whether a set
of commands is included at compile time. Compile-time constants are defined
with #DEFINE.
Commands
Specifies the set of commands that is included at compile time.
Remarks
You can nest an
#IFDEF | #IFNDEF ... #ENDIF structure within another #IFDEF |
#IFNDEF ... #ENDIF structure.
Comments can be
placed on the same line after #IFDEF, #IFNDEF, #ELSE, and #ENDIF. These
comments are ignored during compilation and program execution. |