A textual macro processor applied before compiling C and C++ language programs. This tag can also be used for questions about other compilers/languages derived from or that have identical features, such as the #directives in Objective-C or C#.
The C and C++ programming languages feature a preparatory phase before proper compilation, named preprocessing, which provides the ability for textual inclusion of header files, recursive macro expansions, conditional compilation, use of various constants not defined in the source nor the language itself, and line control.
This step may be provided as a standalone executable, traditionally named cpp
. The preprocessing rules are slightly different for C than for C++; but common compiler collections like gcc and the LLVM-based clang use a single preprocessor for both languages, which can be configured to choose the appropriate rule-set.
Resources
The GNU CPP online manual describes the syntax and use of the GNU implementation of the preprocessor.
The Pre-defined C/C++ Compiler Macros project lists pre-defined compiler macros that can be used to identify standards, compilers, operating systems and hardware architectures at compile-time.
The Microsoft C# Compiler does not have a separate preprocessor, but it has similar directives and operates as if it did.