The preprocessor is executed at translation phase 4, before the compilation. The result of preprocessing is single file which is then passed to the actual compiler.
The preprocessing directives control the behavior of the preprocessor. Each directive occupies one line and has the following format:
- preprocessing instruction (one of
- arguments (depends on the instruction)
- line break
The null directive (
# followed by a line break) is allowed and has no effect.
The preprocessor has the source file translation capabilities:
- conditionally compile of parts of source file (controlled by directive
- replace text macros while possibly concatenating or quoting identifiers (controlled by directives
#undef, and operators
- include other files (controlled by directive
- cause a warning (controlled by directive
- cause an error (controlled by directive
The following aspects of the preprocessor can be controlled:
- implementation defined behavior (controlled by directives
- file name and line information available to the preprocessor (controlled by directives
- ↑ These are the directives defined by the standard. The standard does not define behavior for other directives: they might be ignored, have some useful meaning, or make the program ill-formed. Even if otherwise ignored, they are removed from the source code when the preprocessor is done.