O'Reilly logo

C by Nikolaos D. Tselikas, George S. Tselikis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16

Preprocessor Directives and Macros

Preprocessor is the part of the compiler that processes a C program before its compilation. In this chapter, we’ll discuss how to define and use macros in a C program and then we’ll present preprocessor directives that support the conditional compilation of a C program.

Simple Macros

In previous chapters, we have used the #define directive to define a simple macro, which is a symbolic name associated with a constant value. To define a simple macro, we write

#define macro_name replacement_characters

Typically, most programmers choose capital letters to name a macro in order to distinguish them from program variables. The usual practice is to define all macros with global scope at the top of the program, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required