1CPP(1)                    BSD General Commands Manual                   CPP(1)
2

NAME

4     cpp — C preprocessor
5

SYNOPSIS

7     cpp [-ACEMPtVv] [-D macro[=value]] [-d flags] [-I path] [-i file]
8         [-S path] [-U macro] [infile | -] [outfile]
9

DESCRIPTION

11     The cpp utility is a macro preprocessor used by the pcc(1) compiler.  It
12     is mainly used to include header files, expand macro definitions, discard
13     comments, and perform conditional compilation.  cpp is written to comply
14     with the ISO/IEC 9899:1999 (“ISO C99”) specification.
15
16     The infile input file is optional.  If not provided or the file name is
17     "-" (dash), cpp reads its initial file from standard input.  The outfile
18     output file is also optional, with output written to standard output if
19     not provided.
20
21     The options are as follows:
22
23     -A      For assembler-with-cpp input: treat non-directive lines starting
24             with a # as comments.
25
26     -C      Do not discard comments.
27
28     -D macro[=value]
29             Create a macro definition before processing any input, as if a
30
31                   #define macro value
32
33             directive had appeared in the source.  If value is not set on the
34             command-line, then a value of 1 is used.
35
36     -d flags
37             Modify output according to flags, which can be a list of charac‐
38             ter flags.  The following flags are currently supported:
39
40             M  Do not process any input, but output a list of “#define”
41                statements for all defined macros other than builtin macros
42                (see below).
43
44             any unknown flags are ignored.
45
46     -E      Modify the exit code, if there were any warnings.
47
48     -I path
49             Add path to the list of directories searched by the “#include”
50             directive.  This may be used to override system include directo‐
51             ries (see -S option).  -I may be specified multiple times and is
52             cumulative.
53
54     -i file
55             Include a file before processing any input, as if a
56
57                   #include "file"
58
59             directive had appeared in the source.  -i may be specified multi‐
60             ple times to include several files.
61
62     -M      Instead of producing a processed C code file, output a list of
63             dependencies for make(1), detailing the files that need to be
64             processed when compiling the input.
65
66     -P      Inhibit generation of line markers.  This is sometimes useful
67             when running the preprocessor on something other than C code.
68
69     -S path
70             Add path to the list of system directories searched by the
71             “#include” directive.  The -S option may be specified multiple
72             times and is cumulative.
73
74     -t      Traditional cpp syntax.  Do not define the __TIME__, __DATE__,
75             __STDC__, and __STDC_VERSION__ macros.
76
77     -U macro
78             Undefine a macro before processing any input, as if a
79
80                   #undef macro
81
82             directive had appeared in the source.
83
84     -V      Verbose debugging output.  -V can be repeated for greater detail.
85             (This is only available if the cpp program was built with
86             PCC_DEBUG defined, which is the default).
87
88     -v      Display version.
89
90     The -D, -i and -U options are processed in the order that they appear on
91     the command line, before any input is read but after the command line
92     options have been scanned.
93
94     Files referenced by the “#include” directive as "...", are first looked
95     for in the current directory, then as per ⟨...⟩ files, which are first
96     looked for in the list of directories provided by any -I options, then in
97     the list of system directories provided by any -S options.  Note that cpp
98     does not define any include directories by default; if no -I or -S
99     options are given, then only the current directory will be searched and
100     no system files will be found.
101
102   Builtin Macros
103     A few macros are interpreted inside the cpp program:
104
105     __DATE__  Expands to a quoted string literal containing the date in the
106     form "Mmm dd yyyy", where the names of the months are the same as those
107     generated by the asctime(3) function, and the first character of dd is a
108     space character if the value is less than 10.
109
110     __FILE__  Expands to a quoted string literal containing the presumed name
111     of the current source file.  When reading source from standard input, it
112     expands to "⟨stdin⟩".
113
114     __LINE__  Expands to an integer constant representing the presumed line
115     number of the source line containing the macro.
116
117     __STDC__  Expands to the integer constant “1”, meaning that the compiler
118     conforms to ISO/IEC 9899:1990 (“ISO C90”).
119
120     __STDC_VERSION__  Expands to the integer constant “199901L”, indicating
121     that cpp conforms to ISO/IEC 9899:1999 (“ISO C99”).
122
123     __TIME__  Expands to a quoted string literal containing the time in the
124     form "hh:mm:ss" as generated by the asctime(3) function.
125
126     Also see the -t option.
127

EXIT STATUS

129     The cpp utility exits with one of the following values:
130
131           0       Successfully finished.
132           1       An error occurred.
133           2       The -E option was given, and warnings were issued.
134

SEE ALSO

136     as(1), ccom(1), make(1), pcc(1), asctime(3)
137

HISTORY

139     The cpp command comes from the original Portable C Compiler by S. C.
140     Johnson, written in the late 70's.  The code originates from the V6 pre‐
141     processor with some additions from V7 cpp and ansi/c99 support.
142
143     A lot of the PCC code was rewritten by Anders Magnusson.
144
145     This product includes software developed or owned by Caldera Interna‐
146     tional, Inc.
147
148BSD                            February 26, 2013                           BSD
Impressum