Datasheet

CONDITIONAL COMPILATION
Conditional compilation directives are typically used to make source programs easy
to change and easy to compile in different execution environments. The mikroC
PRO for AVR supports conditional compilation by replacing the appropriate source-
code lines with a blank line.
All conditional compilation directives must be completed in the source or include file
in which they have begun.
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 #if has a
nonzero value, the line group immediately following the #if directive is retained in
the translation unit.
The 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 directive.
Any number of #elif directives can appear between #if and #endif directives, but
at most one #else directive is allowed. The #else directive, if present, must be the
last directive before #endif.
sections can be any program text that has meaning to compiler or preprocessor.
The preprocessor selects a single section by evaluating constant_expression
following each #if or #elif directive until it finds a true (nonzero) constant expres-
sion. The constant expressions are subject to macro expansion.
225
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5