Chapter 9

The C Preprocessor

The C preprocessor is a program that processes a C source file before the compiler translates the program into object code. During processing the C source file, it performs certain modifications on the file based upon instructions or directives to the preprocessor. The preprocessor directives are simply commands that start with a # symbol (character). We will examine these directives one by one in this chapter.

9.1 | MACRO SUBSTITUTION

We have already seen that the #define preprocessor directive is used to create a symbolic constant for use in a program. The general form of this directive is given by:

        #define     macro-name replacement—text

where macro-name is replaced with replacement–text through the program.

For ...

Get C Programming Essentials 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.