Preprocessor Directives

Lesson 14 of 20

Watch #define and #include rewrite your code before the compiler ever sees it — text in, program out.

The big picture

The pass before the pass

Before the compiler runs, the preprocessor rewrites your text: directives starting with # never reach machine code.

A text pass first

Lines starting with # are handled before compilation — they edit the source text itself.

#include pastes

It literally copies the whole header file into your source at that line.

#define swaps

Every later use of the macro name is replaced by its body — no variables, no memory.

Macros can take arguments

#define DOUBLE(x) ((x) * 2) expands like a text template, wherever you call it.