September 2014
Beginner to intermediate
424 pages
10h 4m
English
This chapter expands on conditional compilation directives available in the preprocessor. There is an emphasis on how conditional compilation can be used in embedded programs to use a single source code base to produce firmware for multiple products or product versions.
The use of defined() and getenv() in conditional compilation directives is explained, with examples. The use of conditional compilation directives for debugging and diagnostics is also covered. This chapter shows how global defines supported by most compilers can be used.
Examples and exercises are for the popular PIC® microcontroller manufactured by Microchip.
Keywords
Conditional compilation
Preprocessor
if
ifdef
Defined