7 #ifndef, 8 #undef – ElmoMC SimplIQ Software Manual User Manual
Page 81

SimplIQ
Software Manual
Program Development and Execution
MAN-SIMSW (Ver. 1.4)
6-19
Example:
#define DEBUG_FLAG
. . .
#ifdef DEBUG_FLAG
MO=0
UM=5
MO=1
#endif
In this example, the text between the #ifdef and #endif directives is compiled as
DEBUG_FLAG
was defined previously.
6.4.1.7 #ifndef
The #ifndef directive, as in C, checks for the absence of identifiers defined with #define.
Syntax:
#ifndef identifier
The #ifndef directive checks for the opposite of the condition checked by #ifdef. If the
identifier has not been defined (or its definition has been removed with #undef), the
condition is true (nonzero). Otherwise, the condition is false (0).
Example:
#ifndef DEBUG_FLAG
#define
DEBUG_FLAG
#endif
In this example, DEBUG_FLAG will be defined only if it has not been defined previously. It
prevents the possible redefinition of DEBUG_FLAG.
6.4.1.8 #undef
The #undef directive, as in C, removes the current definition of the specified name. All
subsequent occurrences of the name are processed without replacement.
Syntax:
#undef identifier
The #undef directive must be paired with a #define directive in order to create a region in a
source program in which an identifier has a special meaning.
Unlike the #undef directive in C, with the
SimplIQ
drive, you cannot apply #undef to an
identifier that has not been previously defined. Repetition of the #undef directive with the
same identifier is illegal.
Example:
#define DEBUG_FLAG
. . .
#undef DEBUG_FLAG
In this example, the #undef directive removes the definition of DEBUG_FLAG, previously
created by the #define directive.