Software Manual Owner manual

SimplIQ Software Manual Program Development and Execution
MAN-SIMSW (Ver. 1.4)
6-18
6.4.1.4 #elseif
The #elseif directive marks an optional clause of a conditional-compilation block defined by
an #ifdef or #if directive.
Syntax:
#elseif constant-expression
The directive controls conditional compilation by checking the specified constant
expression. If the expression is non-zero, #elseif directs the Compiler to continue processing
statements up to the next #endif, #else or #elseif directive and then to skip to the statement
after #endif. If the constant expression is zero, #elseif directs the Compiler to skip to the
next #endif, #else or #elseif. Up to 50 #elseif directives can appear between the #if and
#endif directives.
As with the #if directive, the #elseif directive must contain a constant-expression, which is
evaluated to a single value; otherwise it causes an error.
Example:
#if MAX_LEN > 30
#define REDUCE_MAX_LEN 30
#elseif MAX_LEN > 20
#define REDUCE_MAX_LEN 20
#elseif MAX_LEN > 10
#define REDUCe_MAX_LEN 10
#else
#define REDUCE_MAX_LEN 5
#endif
The #if, #elseif and #else directives in this example are used to make one of four choices,
based on the value of
MAX_LEN
. The constant
REDUCE_MAX_LEN
is set to 30, 20, 10 or 5,
depending on the definition of
MAX_LEN
.
6.4.1.5 #endif
Each #endif directive must close an #if directive, in a manner similar to the C language.
Syntax:
endif
The #endif directive without a previous #if directive generates an error.
6.4.1.6 #ifdef
The #ifdef directive, as in C, checks for the presence of identifiers defined with #define.
Syntax:
#ifdef identifier
The #ifdef and #ifndef directives can be used anywhere that #if can be used. The #ifdef
identifier statement is equivalent to #if 1 when identifier has been defined, and is equivalent
to #if 0 when identifier has not been defined or has been undefined with the #undef
directive.