Programming tools / The preprocessor |
Integrate code lines conditionally.
&ifdef identifier ... [&else ...] &endif
&ifndef identifier ... [&else ...] &endif
The &ifdef and &ifndef preprocessor macros can be used to integrate code lines conditionally according to the existence of a preprocessor constant.
The constant is defined with a &define or with the -D option in the command line.
Even if the condition is evaluated to false, the content of the &ifdef block is still scanned and tokenized. Therefore, it must be lexically correct.
Sometimes it is useful to use some code if a macro is not defined. You can use &ifndef, that evaluates to true if the macro is not defined.
&define IS_DEFINED &ifdef IS_DEFINED DISPLAY "The macro is defined" &endif /* IS_DEFINED */
& 1 "A" DISPLAY "The macro is defined"