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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.