xref: /openbsd-src/libexec/tradcpp/tradcpp.1 (revision f9343feac8314427583210aa64cbdde958db9030)
1.\"	$OpenBSD: tradcpp.1,v 1.5 2018/09/02 08:28:05 jsg 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: September 2 2018 $
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.Sy 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 Ar dir
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 debuglog Ar file
265Write a trace of actions and operations to
266.Ar file
267as the input is processed.
268Meant for debugging problems in complex substitution schemes fed to
269.Nm ,
270such as those used by
271.Sy imake .
272.It Fl dD
273Dump all macro definitions, except for the predefined macros, after
274the normal preprocessing output.
275Not implemented.
276.It Fl dI
277Dump all include directives along with the normal preprocessing
278output.
279Not implemented.
280.It Fl dM
281Dump all macro definitions instead of the normal preprocessing
282output.
283Not implemented.
284.It Fl dN
285Like
286.Fl dD
287but emits only macro names and not the expansions.
288Not implemented.
289.It Fl H
290Output a trace of the include tree as it gets processed.
291Not implemented.
292.El
293.Ss Other Options
294.Bl -tag -width bubblebabble
295.It Fl CC
296Retain comments in output.
297Same as
298.Fl C ,
299accepted for compatibility with
300.Xr gcc 1 .
301.It Fl fdollars-in-identifiers , Fl fno-dollars-in-identifiers
302Enable
303.Pq or disable, respectively
304the use of the dollar sign in identifiers.
305Not implemented.
306.It Fl ftabstop=num
307Set the tab width to the specified value, for reporting column
308positions in diagnostics.
309The default is 8.
310Not implemented.
311.It Fl std=standard
312Ask
313.Nm
314to conform to the named standard.
315The default, and the only supported value, is
316.Dq krc .
317.It Fl traditional
318This option is accepted for compatibility with
319.Xr gcc 1
320and ignored.
321.It Fl x Ar lang
322Adjust the preprocessor for the given language.
323The only values accepted for
324.Ar lang
325are
326.Dq assembler-with-cpp
327and
328.Dq c ,
329neither of which have any effect on the behavior of
330.Nm .
331.El
332.Sh FILES
333The default list of directories searched for include files is:
334.Bl -item -offset indent -compact
335.It
336.Pa /usr/local/include
337.It
338.Pa /usr/include
339.El
340.Sh SEE ALSO
341.Xr cc 1 ,
342.Xr cpp 1 ,
343.Xr make 1
344.Sh STANDARDS
345None.
346The whole point of a traditional cpp is that it reflects practices
347in pre-standardization implementations of C.
348Some information is available from the first edition of Kernighan and
349Ritchie.
350Much of the rest of the behavior is based on lore, pragmatism,
351material encountered in the wild, and comparison to other
352implementations.
353.Sh HISTORY
354The original version of
355.Nm
356was written one evening in late 2010.
357This version had some problems and was put aside.
358The first working version was released in June 2013.
359.\" .Sh AUTHORS
360.\" .An David A. Holland
361.Sh BUGS
362Probably plenty.
363