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