cpp(1)cpp(1)Namecpp - the C language preprocessor
/lib/cpp [ option ... ] [ ifile [ ofile ] ]
The command is the C language preprocessor which is invoked as the
first pass of any C compilation using the command. Thus, the output of
is designed to be in a form acceptable as input to the next pass of the
The preferred way to invoke however, is through the command. See for a
general macro processor.
The command optionally accepts two file names as arguments. The ifile
and ofile are, respectively, the input and output for the preprocessor.
They default to standard input and standard output if no argument is
Options-B Strips C++-style comments (begin with // and end
-C Passes along all comments, except those found on
directive lines. By default, strips C-style com‐
-M Generates dependency lists suitable for use with
instead of the normal output.
-P Preprocesses the input without producing the line
control information used by the next pass of the C
-R Permits recursion when a macro is expanded.
-Uname Removes any initial definition of name, where name
is a reserved symbol that is predefined by the pre‐
processor. The symbols predefined by this imple‐
mentation are bsd4_2, ultrix, unix, and vax.
-Dname=def Defines name as if by a #define directive. If no
=def is given, name is defined as 1. The -D option
has lower precedence than the -U option. That is,
if the same name is used in both a -U option and a
-D option, the name remains undefined regardless of
the order of the options.
-Idir Changes the algorithm for searching for #include
files whose names do not begin with a backslash ( /
) to look in dir before looking in the directories
on the standard list. Thus, #include files whose
names are enclosed in quotes ( "" ) will be
searched for first in the directory of the file
with the #include line, then in directories named
in -I options, and, finally, in directories on a
standard list. For #include files whose names are
enclosed in braces (<>), the directory of the file
with the #include line is not searched.
All directives start with lines that begin with a pound sign (#). Any
number of blanks and tabs are allowed between the pound signs and the
directive. The following is a list of the directives:
#define name(arg, ...,arg ) token-string
Replaces subsequent instances of name and the fol‐
lowing set of tokens that is enclosed in parenthe‐
ses by token-string. Each occurrence of an arg in
the token-string is replaced by the corresponding
set of tokens in the comma-separated list. Note
that spaces between name and the left parenthesis
(() are not allowed. When a macro with arguments
is expanded, the arguments are placed unchanged
into the expanded token-string . After the entire
token-string has been expanded, re-starts its scan
for names to expand at the beginning of the newly
#undef name Causes the definition of name (if any) to be for‐
#include <filename> Includes the contents of filename , which will then
be run through When the <filename> notation is
used, filename is searched for in the standard
places. See the -I option above for more detail.
#line integer-constant "filename"
Causes to generate line control information for the
next pass of the C compiler. Integer-constant is
the line number of the next line and filename is
the file that it comes from. If "filename" is not
given, the current file name is unchanged.
Ends a section of lines begun by a test directive
(#if, #ifdef, or #ifndef). Each test directive
must have a matching #endif.
#ifdef name Defines text that will appear in the output if name
has been the subject of a previous #define without
being the subject of an intervening #undef.
#ifndef name Defines text that will not appear in the output if
name has been the subject of a previous #define
without being the subject of an intervening #undef.
Defines text that will appear in the output if con‐
stant-expression is not zero. All binary non-
assignment C operators, which include the ?: ,
minus sign (−), exclamation mark (!), and tilde (~)
are legal in constant-expression. The precedence
of the operators is the same as defined by the C
language. There is also a unary operator defined,
which can be used in constant-expression in these
two forms: defined ( name ) or defined name. This
allows the utility of #ifdef and #ifndef in a #if
directive. Only these operators, integer con‐
stants, and names which are known by should be used
in constant-expression. In particular, the sizeof
operator is not available.
#else Reverses the notion of the test directive which
matches this directive. So if lines prior to this
directive are ignored, the following lines will
appear in the output. The reverse is also true.
Defines text that will appear in the output if the
preceding test directive and all intervening #elif
directives equalled zero and the constant-expres‐
sion did not equal zero. The rules for constant-
expression are the same as for the #if directive.
The test directives and the possible #else and #elif directives can be
In addition to these directives, the System V #ident directive is rec‐
ognized and ignored.
Two special names are understood by __LINE__ is defined as the current
line number (as a decimal integer) and __FILE__ is defined as the cur‐
rent file name (as a C string). They can be used in any situations
where you would use other defined names, including in macros.
The error messages produced by are self-explanatory. The line number
and filename where the error occurred are printed along with the diag‐
/usr/include standard directory for #include files
See Alsocc(1), m4(1).