Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
DIRECTIVES
Directives are words of special significance which provide additional functionality
regarding compilation and output.
The following directives are at your disposal:
- Compiler directives for conditional compilation, 
- Linker directives for object distribution in memory. 
COMPILER DIRECTIVES
Any line in source code with leading 
#
is taken as a compiler directive. The initial #
can be preceded or followed by whitespace (excluding new lines). The compiler
directives are not case sensitive.
You can use conditional compilation to select particular sections of code to compile
while excluding other sections. All compiler directives must be completed in the
source file in which they begun.
Directives #DEFINE and #UNDEFINE
Use directive 
#DEFINE
to define a conditional compiler constant (“flag”). You can use
any identifier for a flag, with no limitations. No conflicts with program identifiers are
possible because the flags have a separate name space. Only one flag can be set
per directive.
For example:
#DEFINE extended_format
Use 
#UNDEFINE
to undefine (“clear”) previously defined flag.
Directives #IFDEF, #ELSEIF and #ELSE
Conditional compilation is carried out by the 
#IFDEF
directive. 
#IFDEF
tests whether
a flag is currently defined or not; i.e. whether the previous 
#DEFINE
directive has
been processed for that flag and is still in force.
The directive 
#IFDEF
is terminated by the 
#ENDIF
directive and can have any num-
ber of the 
#ELSEIF
clauses and an optional 
#ELSE
clause:
164
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5