Phases of Preprocessing

Preprocessing appears as if it occurs in several phases.

  1. New-line characters are introduced as needed to replace system-dependent end-of-line indicators, and any other system-dependent character-set translations are done. Equivalent single characters replace trigraph sequences. Universal-character-names replace characters not in the basic source character set.
  2. Each \ (backslash) followed by a new-line character pair is deleted. The next source line is appended to the line that contained the sequence.
  3. The source text is decomposed into preprocessing tokens and sequences of white space. A single white space replaces each comment. A source file cannot end with a partial token or comment.
  4. Preprocessing directives are executed, and macros are expanded.
  5. Escape sequences or universal-character-names in character constants and string literals are replaced by their equivalent values.
  6. Adjacent string literals are concatenated.

The rest of the compilation process operates on the preprocessor output, which is syntactically and semantically analyzed and translated, and then linked as necessary with other programs and libraries.



Preprocessor Directives - An Overview