2 .\" Copyright (c) 2013 The NetBSD Foundation, Inc.
3 .\" All rights reserved.
5 .\" This code is derived from software contributed to The NetBSD Foundation
6 .\" by David A. Holland.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
17 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 .\" POSSIBILITY OF SUCH DAMAGE.
34 .Nd traditional (K&R-style) C macro preprocessor
38 .Op Ar input-file Op Ar output-file
42 command provides a traditional K&R-style C macro preprocessor.
43 It is intended to be suitable for historical Unix uses of the
46 particularly those that depend on preservation of whitespace.
48 The chief ways in which traditional cpp differs from
50 .Bl -bullet -offset indent
52 Macro arguments are expanded within quoted strings.
53 There is no stringize operator.
55 There is no token pasting operator; tokens can be concatenated by
56 placing comments between them.
57 This process is also not limited to valid C language tokens.
59 Whitespace is preserved, and in particular tabs are not expanded into
61 Furthermore, additional whitespace is not injected.
65 has many options, many of which are defined for compatibility with
68 Many of the options are not yet implemented.
69 .\" The option lists have been sorted in what I hope is a sensible
70 .\" order. Please don't arbitrarily alphabetize them.
72 .Bl -tag -width bubblebabble
74 Retain comments in output.
75 .It Fl Dmacro[=expansion]
76 Provide a definition for the named macro.
77 If no expansion is provided, the value
80 Note that like many Unix compilers,
82 does not accept a space between the
86 Add the specified path to the main list of include directories.
87 Note that like many Unix compilers,
89 does not accept a space between the
91 and the directory name.
93 Do not search the standard system include directories.
95 Suppress line number information in the output.
96 Currently line number information is not generated at all and this
99 Remove any existing definition for the named macro.
100 Note that like many Unix compilers,
102 does not accept a space between the
106 Remove all predefined macros.
109 Warning options can be disabled or enabled by inserting, or not, the
114 and the warning name.
117 form is shown for options that are enabled by default.
118 .Bl -tag -width bubblebabble
120 Turn on all warnings.
123 disables only the warnings that are disabled by default.
125 Turn off all warnings.
127 Make warnings into fatal errors.
129 Warn about nested comments.
130 .It Fl Wno-endif-labels
131 Don't warn about symbols attached to #endif directives.
132 (The warning is currently not implemented.)
134 Warn about undefined symbols appearing in #if and #elif expressions.
135 .It Fl Wunused-macros
136 Warn about macros that are defined and never used.
140 .Bl -tag -width bubblebabble
142 Generate dependency information for
144 on the standard output, instead of preprocessing.
149 but skip system headers.
154 but write the dependency information to a file named after the input
157 and preprocess normally to standard output.
162 but skip system headers.
165 Send dependency output to the named file instead of the default
169 When generating dependency information, assume that missing files are
170 generated instead of failing.
173 Issue dummy rules for all include files.
176 from choking if an include file is removed.
183 metacharacters appearing in the target are escaped.
187 target appearing in the generated dependency information.
188 The default is the name of the input file with its suffix replaced
189 with the suffix for object files, normally
191 .\" If this option is given more than once, all named targets will
193 .\" (The current operating mode framework doesn't support that.)
195 .Ss More Include Path Options
196 .Bl -tag -width bubblebabble
197 .It Fl idirafter Ar path
198 Add the specified path to the
201 This path is searched after all directories specified with
203 and the standard system directories.
204 Directories on this path are treated as containing system include
206 .It Fl imacros Ar file
209 prior to reading the main input file, and preprocess it, but throw
210 away the output and retain only the macro definitions.
211 .It Fl include Ar file
212 Read in and preprocess
214 prior to reading the main input file.
215 .It Fl iprefix Ar prefix
216 Set the path prefix used with the
219 .It Fl iquote Ar path
222 to the list of directories searched for include directives written
224 This list is not searched for include directives written with angle
226 .It Fl iremap Ar string:replacement
235 .It Fl isysroot Ar path
240 that is, the directory under which the standard system paths are found.
241 .It Fl isystem Ar path
244 to the list of system include directories.
245 This list is searched after the list given with
247 Files found on this path are treated as system headers.
248 .It Fl iwithprefix Ar dir
251 onto the prefix given with
253 and add this directory as if it were specified with
255 .It Fl iwithprefixbefore
258 but adds the result as if it were specified with
261 .Ss Diagnostic Options
262 .Bl -tag -width bubblebabble
263 .It Fl debuglog Ar file
264 Write a trace of actions and operations to
266 as the input is processed.
267 Meant for debugging problems in complex substitution schemes fed to
269 such as those used by
272 Dump all macro definitions, except for the predefined macros, after
273 the normal preprocessing output.
276 Dump all include directives along with the normal preprocessing
280 Dump all macro definitions instead of the normal preprocessing
286 but emits only macro names and not the expansions.
289 Output a trace of the include tree as it gets processed.
293 .Bl -tag -width bubblebabble
295 Retain comments in output.
298 accepted for compatibility with
300 .It Fl fdollars-in-identifiers , Fl fno-dollars-in-identifiers
302 .Pq or disable, respectively
303 the use of the dollar sign in identifiers.
306 Set the tab width to the specified value, for reporting column
307 positions in diagnostics.
313 to conform to the named standard.
314 The default, and the only supported value, is
317 This option is accepted for compatibility with
321 Adjust the preprocessor for the given language.
322 The only values accepted for
325 .Dq assembler-with-cpp
328 neither of which have any effect on the behavior of
332 The default list of directories searched for include files is:
333 .Bl -item -offset indent -compact
335 .Pa /usr/local/include
345 The whole point of a traditional cpp is that it reflects practices
346 in pre-standardization implementations of C.
347 Some information is available from the first edition of Kernighan and
349 Much of the rest of the behavior is based on lore, pragmatism,
350 material encountered in the wild, and comparison to other
353 The original version of
355 was written one evening in late 2010.
356 This version had some problems and was put aside.
357 The first working version was released in June 2013.
359 .\" .An David A. Holland