xref: /openbsd/libexec/tradcpp/tradcpp.1 (revision a6445c1d)
1.\"	$OpenBSD: tradcpp.1,v 1.2 2014/08/08 20:50:28 jmc Exp $
2.\"
3.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by David A. Holland.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd $Mdocdate: August 8 2014 $
31.Dt TRADCPP 1
32.Os
33.Sh NAME
34.Nm tradcpp
35.Nd traditional (K&R-style) C macro preprocessor
36.Sh SYNOPSIS
37.Nm tradcpp
38.Op Fl options
39.Op Ar input-file Op Ar output-file
40.Sh DESCRIPTION
41The
42.Nm
43command provides a traditional K&R-style C macro preprocessor.
44It is intended to be suitable for historical Unix uses of the
45preprocessor, such as
46.Xr imake ,
47particularly those that depend on preservation of whitespace.
48.Pp
49The chief ways in which traditional cpp differs from
50Standard C are:
51.Bl -bullet -offset indent
52.It
53Macro arguments are expanded within quoted strings.
54There is no stringize operator.
55.It
56There is no token pasting operator; tokens can be concatenated by
57placing comments between them.
58This process is also not limited to valid C language tokens.
59.It
60Whitespace is preserved, and in particular tabs are not expanded into
61spaces.
62Furthermore, additional whitespace is not injected.
63.El
64.Sh OPTIONS
65.Nm
66has many options, many of which are defined for compatibility with
67.Xr gcc 1
68or other compilers.
69Many of the options are not yet implemented.
70.\" The option lists have been sorted in what I hope is a sensible
71.\" order. Please don't arbitrarily alphabetize them.
72.Ss Common Options
73.Bl -tag -width bubblebabble
74.It Fl C
75Retain comments in output.
76.It Fl Dmacro[=expansion]
77Provide a definition for the named macro.
78If no expansion is provided, the value
79.Dq 1
80is used.
81Note that like many Unix compilers,
82.Nm
83does not accept a space between the
84.Dq D
85and the macro name.
86.It Fl Ipath
87Add the specified path to the main list of include directories.
88Note that like many Unix compilers,
89.Nm
90does not accept a space between the
91.Dq I
92and the directory name.
93.It Fl nostdinc
94Do not search the standard system include directories.
95.It Fl P
96Suppress line number information in the output.
97Currently line number information is not generated at all and this
98option has no effect.
99.It Fl Umacro
100Remove any existing definition for the named macro.
101Note that like many Unix compilers,
102.Nm
103does not accept a space between the
104.Dq U
105and the macro name.
106.It Fl undef
107Remove all predefined macros.
108.El
109.Ss Warning Options
110Warning options can be disabled or enabled by inserting, or not, the
111string
112.Dq no-
113between the
114.Dq W
115and the warning name.
116Herein the
117.Dq Fl Wno-
118form is shown for options that are enabled by default.
119.Bl -tag -width bubblebabble
120.It Fl Wall
121Turn on all warnings.
122The option
123.Fl Wno-all
124disables only the warnings that are disabled by default.
125.It Fl w
126Turn off all warnings.
127.It Fl Werror
128Make warnings into fatal errors.
129.It Fl Wcomment
130Warn about nested comments.
131.It Fl Wno-endif-labels
132Don't warn about symbols attached to #endif directives.
133(The warning is currently not implemented.)
134.It Fl Wundef
135Warn about undefined symbols appearing in #if and #elif expressions.
136.It Fl Wunused-macros
137Warn about macros that are defined and never used.
138Not implemented.
139.El
140.Ss Depend Options
141.Bl -tag -width bubblebabble
142.It Fl M
143Generate dependency information for
144.Xr make 1
145on the standard output, instead of preprocessing.
146Not implemented.
147.It Fl MD
148Like
149.Fl M
150but skip system headers.
151Not implemented.
152.It Fl MM
153Like
154.Fl M
155but write the dependency information to a file named after the input
156file with extension
157.Pa \.d
158and preprocess normally to standard output.
159Not implemented.
160.It Fl MMD
161Like
162.Fl MM
163but skip system headers.
164Not implemented.
165.It Fl MF Ar file
166Send dependency output to the named file instead of the default
167location.
168Not implemented.
169.It Fl MG
170When generating dependency information, assume that missing files are
171generated instead of failing.
172Not implemented.
173.It Fl MP
174Issue dummy rules for all include files.
175This prevents
176.Xr make 1
177from choking if an include file is removed.
178Not implemented.
179.It Fl MQ Ar target
180Same as
181.Fl MT
182except that any
183.Xr make 1
184metacharacters appearing in the target are escaped.
185.It Fl MT Ar target
186Set the name of the
187.Xr make 1
188target appearing in the generated dependency information.
189The default is the name of the input file with its suffix replaced
190with the suffix for object files, normally
191.Pa .o .
192.\" If this option is given more than once, all named targets will
193.\" be emitted.
194.\" (The current operating mode framework doesn't support that.)
195.El
196.Ss More Include Path Options
197.Bl -tag -width bubblebabble
198.It Fl idirafter Ar path
199Add the specified path to the
200.Dq afterwards
201include path.
202This path is searched after all directories specified with
203.Fl I
204and the standard system directories.
205Directories on this path are treated as containing system include
206files.
207.It Fl imacros Ar file
208Read in
209.Ar file
210prior to reading the main input file, and preprocess it, but throw
211away the output and retain only the macro definitions.
212.It Fl include Ar file
213Read in and preprocess
214.Ar file
215prior to reading the main input file.
216.It Fl iprefix Ar prefix
217Set the path prefix used with the
218.Fl iwithprefix
219option.
220.It Fl iquote Ar path
221Add
222.Ar path
223to the list of directories searched for include directives written
224with quotes.
225This list is not searched for include directives written with angle
226brackets.
227.It Fl iremap Ar string:replacement
228Substitute
229.Ar replacement
230for
231.Ar string
232in the
233.Dv __FILE__
234built-in macro.
235Not supported.
236.It Fl isysroot Ar path
237Use
238.Ar path
239as the
240.Dq system root ,
241that is, the directory under which the standard system paths are found.
242.It Fl isystem Ar path
243Add
244.Ar path
245to the list of system include directories.
246This list is searched after the list given with
247.Ar I .
248Files found on this path are treated as system headers.
249.It Fl iwithprefix Ar dir
250Splice
251.Ar dir
252onto the prefix given with
253.Fl iprefix
254and add this directory as if it were specified with
255.Fl idirafter .
256.It Fl iwithprefixbefore
257Like
258-Fl iwithprefix
259but adds the result as if it were specified with
260.Fl I .
261.El
262.Ss Diagnostic Options
263.Bl -tag -width bubblebabble
264.It Fl dD
265Dump all macro definitions, except for the predefined macros, after
266the normal preprocessing output.
267Not implemented.
268.It Fl dI
269Dump all include directives along with the normal preprocessing
270output.
271Not implemented.
272.It Fl dM
273Dump all macro definitions instead of the normal preprocessing
274output.
275Not implemented.
276.It Fl dN
277Like
278.Fl dD
279but emits only macro names and not the expansions.
280Not implemented.
281.It Fl H
282Output a trace of the include tree as it gets processed.
283Not implemented.
284.El
285.Ss Other Options
286.Bl -tag -width bubblebabble
287.It Fl CC
288Retain comments in output.
289Same as
290.Fl C ,
291accepted for compatibility with
292.Xr gcc 1 .
293.It Fl fdollars-in-identifiers , Fl fno-dollars-in-identifiers
294Enable
295.Pq or disable, respectively
296the use of the dollar sign in identifiers.
297Not implemented.
298.It Fl ftabstop=num
299Set the tab width to the specified value, for reporting column
300positions in diagnostics.
301The default is 8.
302Not implemented.
303.It Fl std=standard
304Ask
305.Nm
306to conform to the named standard.
307The default, and the only supported value, is
308.Dq krc .
309.It Fl traditional
310This option is accepted for compatibility with
311.Xr gcc 1
312and ignored.
313.It Fl x Ar lang
314Adjust the preprocessor for the given language.
315The only values accepted for
316.Ar lang
317are
318.Dq assembler-with-cpp
319and
320.Dq c ,
321neither of which have any effect on the behavior of
322.Nm .
323.El
324.Sh FILES
325The default list of directories searched for include files is:
326.Bl -item -offset indent -compact
327.It
328.Pa /usr/local/include
329.It
330.Pa /usr/include
331.El
332.Sh SEE ALSO
333.Xr cc 1 ,
334.Xr cpp 1 ,
335.Xr make 1
336.Sh STANDARDS
337None.
338The whole point of a traditional cpp is that it reflects practices
339in pre-standardization implementations of C.
340Some information is available from the first edition of Kernighan and
341Ritchie.
342Much of the rest of the behavior is based on lore, pragmatism,
343material encountered in the wild, and comparison to other
344implementations.
345.Sh HISTORY
346The original version of
347.Nm
348was written one evening in late 2010.
349This version had some problems and was put aside.
350The first working version was released in June 2013.
351.\" .Sh AUTHORS
352.\" .An David A. Holland
353.Sh BUGS
354Probably plenty.
355