C++ › Preprocessor & Macros

What is the C++ preprocessor?

Beginner

Answer

The preprocessor is a text-processing step that runs before compilation, handling directives beginning with # : #include (textual inclusion of headers), #define (macros), and conditional compilation (#if/#ifdef/#endif). It manipulates source text, not C++ semantics, so it has no knowledge of types or scope.
#include <vector>      // textual inclusion
#define PI 3.14159       // macro substitution
Real-world example The preprocessor stitches headers into each translation unit before the compiler proper runs.

Common follow-ups: When does the preprocessor run? | Does it understand C++ types?