The Translation Phasessuggest change
As of the C 2011 Standard, listed in §126.96.36.199 Translation Phases, the translation of source code to program image (e.g., the executable) are listed to occur in 8 ordered steps.
- The source file input is mapped to the source character set (if necessary). Trigraphs are replaced in this step.
- Continuation lines (lines that end with
\\) are spliced with the next line.
- The source code is parsed into whitespace and preprocessing tokens.
- The preprocessor is applied, which executes directives, expands macros, and applies pragmas. Each source file pulled in by
#includeundergoes translation phases 1 through 4 (recursively if necessary). All preprocessor related directives are then deleted.
- Source character set values in character constants and string literals are mapped to the execution character set.
- String literals adjacent to each other are concatenated.
- The source code is parsed into tokens, which comprise the translation unit.
- External references are resolved, and the program image is formed.
An implementation of a C compiler may combine several steps together, but the resulting image must still behave as if the above steps had occurred separately in the order listed above.