Files in this directory form the C preprocessor, which handles '#include'
files and macro definition and expansion for the C compiler.
This new version was written by John F. Reiser and is from 5 to 12
times faster than the old.
To create the executable file 'cpp' in the current directory:
To install the preprocessor 'cpp' so it will be used by the C compiler:
: backup the existing version
: install the new version
Documentation clarifications:
Symbols defined on the command line by "-Dfoo" are defined as "1",
i.e., as if they had been defined by "#define foo 1" or "-Dfoo=1".
An unescaped linefeed (the single character "\n") terminates a
character constant or quoted string.
An escaped linefeed (the two-character sequence "\\\n") may be
used in the body of a '#define' statement to continue
the definition onto the next line. The escaped linefeed is
not included in the macro body.
Comments are uniformly removed. They are also ignored, except
that a comment terminates a token.
Thus "foo/* la di da */bar" may expand 'foo' and 'bar' but
will never expand 'foobar'. If neither 'foo' nor 'bar' is a
macro then the output is "foobar", even if 'foobar'
is defined as something else. The file
produces "21" because the comment causes a break which enables
the recognition of 'b' and 'a' as formals in the string "b/**/a".
Macro formals are recognized even inside character constants
and quoted strings. The output from
is the seven characters " '\\bar'".
Macros are not expanded while processing a '#define' or '#undef'.
Macros are not expanded during the scan which determines the actual
parameters to another macro call. Thus
produces " bye" (and warns about the redefinition of 'bar').
There are some differences between the new and the old preprocessor.
"1.e4" is recognized as a floating-point number, rather than as an
opportunity to expand the possible macro name "e4".
Any kind and amount of white space (space, tab, linefeed, vertical tab,
formfeed, carriage return) is allowed between a macro name and
the left parenthesis which introduces its actual parameters.
The comma operator is legal in preprocessor '#if' statements.
Macros with parameters are legal in preprocessor '#if' statements.
Single-character character constants are legal in preprocessor '#if' statements.
Linefeeds are put out in the proper place when a multiline comment
is not passed through to the output.
The following example expands to "# # #" :
Recursion in macro definitions is strictly obeyed (to the extent that
space is available). In particular,
causes an infinite loop with very little output. The tail recursion
causes the string "<>" to be output infinitely many times. The
complains "too much pushback", dumps the pushback, and continues
Nothing (not even linefeeds) is output while a false '#if', '#ifdef',
or '#ifndef' is in effect. Thus when all conditions become true
a line of the form "# 12345 foo.c" is output.
Error and warning messages always appear on standard error (file
Mismatch between the number of formals and actuals in a macro call
produces only a warning, and not an error. Excess actuals
are ignored; missing actuals are turned into null strings.
The virgule '/' in "a=/*b" is interpreted as the first character of
the pair "/*" which introduces a comment, rather than as the
second character of the divide-and-replace operator "=/".
This incompatibility reflects the recent change in the C language
which made "a/=*b" the legal way to write such a statement
if the meaning "a=a/ *b" is intended.