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