(cpp.info)Global Actions

Next: Commands Prev: Top Up: Top

Transformations Made Globally

   Most C preprocessor features are inactive unless you give specific
commands to request their use.  (Preprocessor commands are lines
starting with `#'; Note: Commands.).  But there are three
transformations that the preprocessor always makes on all the input it
receives, even in the absence of commands.

   * All C comments are replaced with single spaces.

   * Backslash-Newline sequences are deleted, no matter where.  This
     feature allows you to break long lines for cosmetic purposes
     without changing their meaning.

   * Predefined macro names are replaced with their expansions (*note

   The first two transformations are done *before* nearly all other
parsing and before preprocessor commands are recognized.  Thus, for
example, you can split a line cosmetically with Backslash-Newline
anywhere (except when trigraphs are in use; see below).

     */ # /*
     */ defi\
     ne FO\
     O 10\

is equivalent into `#define FOO 1020'.  You can split even an escape
sequence with Backslash-Newline.  For example, you can split `"foo\bar"'
between the `\' and the `b' to get


This behavior is unclean: in all other contexts, a Backslash can be
inserted in a string constant as an ordinary character by writing a
double Backslash, and this creates an exception.  But the ANSI C
standard requires it.  (Strict ANSI C does not allow Newlines in string
constants, so they do not consider this a problem.)

   But there are a few exceptions to all three transformations.

   * C comments and predefined macro names are not recognized inside a
     `#include' command in which the file name is delimited with `<'
     and `>'.

   * C comments and predefined macro names are never recognized within a
     character or string constant.  (Strictly speaking, this is the
     rule, not an exception, but it is worth noting here anyway.)

   * Backslash-Newline may not safely be used within an ANSI "trigraph".
     Trigraphs are converted before Backslash-Newline is deleted.  If
     you write what looks like a trigraph with a Backslash-Newline
     inside, the Backslash-Newline is deleted as usual, but it is then
     too late to recognize the trigraph.

     This exception is relevant only if you use the `-trigraphs' option
     to enable trigraph processing.  Note: Invocation.

automatically generated by info2www