Skip to Content
Embedded C Programming
book

Embedded C Programming

by Mark Siegesmund
September 2014
Beginner to intermediate
424 pages
10h 4m
English
Newnes
Content preview from Embedded C Programming
Chapter 14

Conditional Compilation

Abstract

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical C Programming

Practical C Programming

B. M. Harwani

Publisher Resources

ISBN: 9780128013144