Using the Preprocessor

Using
the
Preprocessor
A preprocessor directive is a non executable statement that informs the compiler how to compile. For example, some microcontroller have certain hardware features that others don’t. A pre-processor directive can be used to inform the compiler to add or remove source code, based on that particular devices ability to support that hardware.
It’s important to note that the preprocessor works with directives on a line by line basis. It is therefore important to ensure that each directive is on a line of its own. Don’t place directives and source code on the same line.
It’s also important not to mistake the compiler’s preprocessor with the assembler’s preprocessor. Any directive that starts with a dollar “$” is the compiler’s preprocessor, and any directive that starts with a hash “#” is the assembler’s preprocessor. They cannot be mixed, as each has no knowledge of the other.
Preprocessor directives can be nested in the same way as source code statements. For example:
$ifdef MyValue
$if MyValue = 10
Symbol CodeConst = 10
$else
Symbol CodeConst = 0
$endif
$endif
Preprocessor directives are lines included in the code of the program that are not BASIC language statements but directives for the preprocessor itself. The preprocessor is actually a separate entity to the compiler, and, as the name suggests, pre-processes the BASIC code before the actual compiler sees it. Preprocessor directives are always preceded by a dollar sign “$”.