Chapter 3

Preprocessor Directives

Abstract

This chapter explains how C programs are processed in two distinct steps. The preprocessor stage and the preprocessor directives are the focus of this chapter.

The ANSI required directives are each explained with examples of their use. This includes the very popular define used for textual replacements to improve both program readability and maintainability.

In addition this chapter covers compiler-specific directives required for programming embedded microcontrollers. Examples show setting processor configuration bits, oscillator types, and speed as well as accessing processor registers. Conditional compilation and macros are introduced; however, they are covered in detail on other chapters.

Get Embedded C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.