ABL electronic PIC16 Personal Computer User Manual


 
Directives #if, #elif, #else, and #endif
The conditional directives #if, #elif, #else, and #endif work very similar to
the common C conditional statements. If the expression you write after the #if
has a nonzero value, the line group immediately following the #if directive is
retained in the translation unit.
Syntax is:
#if
constant_expression_1
<
section_1
>
[#elif
constant_expression_2
<
section_2
>]
...
[#elif
constant_expression_n
<
section_n
>]
[#else
<
final_section
>]
#endif
Each #if directive in a source file must be matched by a closing #endif direc-
tive. Any number of #elif directives can appear between the #if and #endif
directives, but at most one #else directive is allowed. The #else directive, if
present, must be the last directive before
#endif.
The sections can be any program text that has meaning to the compiler or the pre-
processor. The preprocessor selects a single section by evaluating the
constant_expression
following each #if or #elif directive until it finds a
true (nonzero) constant expression. The
constant_expressions
are subject to
macro expansion.
If all occurrences of constant-expression are false, or if no
#elif directives
appear, the preprocessor selects the text block after the
#else clause. If the
#else clause is omitted and all instances of
constant_expression
in the #if
block are false, no section is selected for further processing.
MikroElektronika:
Development
tools
-
Books
-
Compilers
13 3
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...