$OpenBSD: tradcpp.1,v 1.5 2018/09/02 08:28:05 jsg Exp $

Copyright (c) 2013 The NetBSD Foundation, Inc.
All rights reserved.

This code is derived from software contributed to The NetBSD Foundation
by David A. Holland.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

.Dd $Mdocdate: December 28 2016 $ .Dt TRADCPP 1 .Os .Sh NAME .Nm tradcpp .Nd traditional (K&R-style) C macro preprocessor .Sh SYNOPSIS .Nm tradcpp .Op Fl options .Op Ar input-file Op Ar output-file .Sh DESCRIPTION The .Nm command provides a traditional K&R-style C macro preprocessor. It is intended to be suitable for historical Unix uses of the preprocessor, such as .Sy imake , particularly those that depend on preservation of whitespace.

p The chief ways in which traditional cpp differs from Standard C are: l -bullet -offset indent t Macro arguments are expanded within quoted strings. There is no stringize operator. t There is no token pasting operator; tokens can be concatenated by placing comments between them. This process is also not limited to valid C language tokens. t Whitespace is preserved, and in particular tabs are not expanded into spaces. Furthermore, additional whitespace is not injected. .El .Sh OPTIONS .Nm has many options, many of which are defined for compatibility with .Xr gcc 1 or other compilers. Many of the options are not yet implemented. The option lists have been sorted in what I hope is a sensible
order. Please don't arbitrarily alphabetize them.
.Ss Common Options l -tag -width bubblebabble t Fl C Retain comments in output. t Fl Dmacro[=expansion] Provide a definition for the named macro. If no expansion is provided, the value .Dq 1 is used. Note that like many Unix compilers, .Nm does not accept a space between the .Dq D and the macro name. t Fl Ipath Add the specified path to the main list of include directories. Note that like many Unix compilers, .Nm does not accept a space between the .Dq I and the directory name. t Fl nostdinc Do not search the standard system include directories. t Fl P Suppress line number information in the output. Currently line number information is not generated at all and this option has no effect. t Fl Umacro Remove any existing definition for the named macro. Note that like many Unix compilers, .Nm does not accept a space between the .Dq U and the macro name. t Fl undef Remove all predefined macros. .El .Ss Warning Options Warning options can be disabled or enabled by inserting, or not, the string .Dq no- between the .Dq W and the warning name. Herein the .Dq Fl Wno- form is shown for options that are enabled by default. l -tag -width bubblebabble t Fl Wall Turn on all warnings. The option .Fl Wno-all disables only the warnings that are disabled by default. t Fl w Turn off all warnings. t Fl Werror Make warnings into fatal errors. t Fl Wcomment Warn about nested comments. t Fl Wno-endif-labels Don't warn about symbols attached to #endif directives. (The warning is currently not implemented.) t Fl Wundef Warn about undefined symbols appearing in #if and #elif expressions. t Fl Wunused-macros Warn about macros that are defined and never used. Not implemented. .El .Ss Depend Options l -tag -width bubblebabble t Fl M Generate dependency information for .Xr make 1 on the standard output, instead of preprocessing. Not implemented. t Fl MD Like .Fl M but skip system headers. Not implemented. t Fl MM Like .Fl M but write the dependency information to a file named after the input file with extension

a \.d and preprocess normally to standard output. Not implemented. t Fl MMD Like .Fl MM but skip system headers. Not implemented. t Fl MF Ar file Send dependency output to the named file instead of the default location. Not implemented. t Fl MG When generating dependency information, assume that missing files are generated instead of failing. Not implemented. t Fl MP Issue dummy rules for all include files. This prevents .Xr make 1 from choking if an include file is removed. Not implemented. t Fl MQ Ar target Same as .Fl MT except that any .Xr make 1 metacharacters appearing in the target are escaped. t Fl MT Ar target Set the name of the .Xr make 1 target appearing in the generated dependency information. The default is the name of the input file with its suffix replaced with the suffix for object files, normally

a .o . If this option is given more than once, all named targets will
be emitted.
(The current operating mode framework doesn't support that.)
.El .Ss More Include Path Options l -tag -width bubblebabble t Fl idirafter Ar path Add the specified path to the .Dq afterwards include path. This path is searched after all directories specified with .Fl I and the standard system directories. Directories on this path are treated as containing system include files. t Fl imacros Ar file Read in .Ar file prior to reading the main input file, and preprocess it, but throw away the output and retain only the macro definitions. t Fl include Ar file Read in and preprocess .Ar file prior to reading the main input file. t Fl iprefix Ar prefix Set the path prefix used with the .Fl iwithprefix option. t Fl iquote Ar path Add .Ar path to the list of directories searched for include directives written with quotes. This list is not searched for include directives written with angle brackets. t Fl iremap Ar string:replacement Substitute .Ar replacement for .Ar string in the .Dv __FILE__ built-in macro. Not supported. t Fl isysroot Ar path Use .Ar path as the .Dq system root , that is, the directory under which the standard system paths are found. t Fl isystem Ar path Add .Ar path to the list of system include directories. This list is searched after the list given with .Ar I . Files found on this path are treated as system headers. t Fl iwithprefix Ar dir Splice .Ar dir onto the prefix given with .Fl iprefix and add this directory as if it were specified with .Fl idirafter . t Fl iwithprefixbefore Ar dir Like .Fl iwithprefix but adds the result as if it were specified with .Fl I . .El .Ss Diagnostic Options l -tag -width bubblebabble t Fl debuglog Ar file Write a trace of actions and operations to .Ar file as the input is processed. Meant for debugging problems in complex substitution schemes fed to .Nm , such as those used by .Sy imake . t Fl dD Dump all macro definitions, except for the predefined macros, after the normal preprocessing output. Not implemented. t Fl dI Dump all include directives along with the normal preprocessing output. Not implemented. t Fl dM Dump all macro definitions instead of the normal preprocessing output. Not implemented. t Fl dN Like .Fl dD but emits only macro names and not the expansions. Not implemented. t Fl H Output a trace of the include tree as it gets processed. Not implemented. .El .Ss Other Options l -tag -width bubblebabble t Fl CC Retain comments in output. Same as .Fl C , accepted for compatibility with .Xr gcc 1 . t Fl fdollars-in-identifiers , Fl fno-dollars-in-identifiers Enable

q or disable, respectively the use of the dollar sign in identifiers. Not implemented. t Fl ftabstop=num Set the tab width to the specified value, for reporting column positions in diagnostics. The default is 8. Not implemented. t Fl std=standard Ask .Nm to conform to the named standard. The default, and the only supported value, is .Dq krc . t Fl traditional This option is accepted for compatibility with .Xr gcc 1 and ignored. t Fl x Ar lang Adjust the preprocessor for the given language. The only values accepted for .Ar lang are .Dq assembler-with-cpp and .Dq c , neither of which have any effect on the behavior of .Nm . .El .Sh FILES The default list of directories searched for include files is: l -item -offset indent -compact t

a /usr/local/include t

a /usr/include .El .Sh SEE ALSO .Xr cc 1 , .Xr cpp 1 , .Xr make 1 .Sh STANDARDS None. The whole point of a traditional cpp is that it reflects practices in pre-standardization implementations of C. Some information is available from the first edition of Kernighan and Ritchie. Much of the rest of the behavior is based on lore, pragmatism, material encountered in the wild, and comparison to other implementations. .Sh HISTORY The original version of .Nm was written one evening in late 2010. This version had some problems and was put aside. The first working version was released in June 2013. .Sh AUTHORS
.An David A. Holland
.Sh BUGS Probably plenty.