[a7de7182] | 1 | .\" $Id: cpp.1,v 1.11 2010/04/05 13:13:57 reed Exp $
|
---|
| 2 | .\" $NetBSD$
|
---|
| 3 | .\" $OpenBSD$
|
---|
| 4 | .\"
|
---|
| 5 | .\" Copyright (c) 2007 Jeremy C. Reed <reed@reedmedia.net>
|
---|
| 6 | .\"
|
---|
| 7 | .\" Permission to use, copy, modify, and/or distribute this software for any
|
---|
| 8 | .\" purpose with or without fee is hereby granted, provided that the above
|
---|
| 9 | .\" copyright notice and this permission notice appear in all copies.
|
---|
| 10 | .\"
|
---|
| 11 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM
|
---|
| 12 | .\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
---|
| 13 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND
|
---|
| 14 | .\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
---|
| 15 | .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
---|
| 16 | .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
---|
| 17 | .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
---|
| 18 | .\" THIS SOFTWARE.
|
---|
| 19 | .\"
|
---|
| 20 | .Dd September 17, 2007
|
---|
| 21 | .Dt CPP 1
|
---|
| 22 | .Os
|
---|
| 23 | .Sh NAME
|
---|
| 24 | .Nm cpp
|
---|
| 25 | .Nd C preprocessor
|
---|
| 26 | .Sh SYNOPSIS
|
---|
| 27 | .Nm
|
---|
| 28 | .\" TODO also document -Dvar and below without spaces?
|
---|
| 29 | .Op Fl CdMtVv
|
---|
| 30 | .Op Fl D Ar macro[=value]
|
---|
| 31 | .Op Fl I Ar path
|
---|
| 32 | .Op Fl i Ar file
|
---|
| 33 | .Op Fl S Ar path
|
---|
| 34 | .Op Fl U Ar macro
|
---|
| 35 | .Op Ar infile | -
|
---|
| 36 | .Op Ar outfile
|
---|
| 37 | .Sh DESCRIPTION
|
---|
| 38 | The
|
---|
| 39 | .Nm
|
---|
| 40 | utility is a macro preprocessor used by the
|
---|
| 41 | .Xr pcc 1
|
---|
| 42 | compiler.
|
---|
| 43 | It is used to include header files,
|
---|
| 44 | expand macro definitions,
|
---|
| 45 | and perform conditional compilation.
|
---|
| 46 | .Pp
|
---|
| 47 | The
|
---|
| 48 | .Ar infile
|
---|
| 49 | input file is optional.
|
---|
| 50 | If not provided or the file name is
|
---|
| 51 | .Qq -
|
---|
| 52 | (dash),
|
---|
| 53 | .Nm
|
---|
| 54 | reads its initial file from standard input.
|
---|
| 55 | The
|
---|
| 56 | .Ar outfile
|
---|
| 57 | output file is also optional.
|
---|
| 58 | It writes by default to standard output.
|
---|
| 59 | .Pp
|
---|
| 60 | .\" TODO: document MAXARG 250 args to a macro, limited by char value
|
---|
| 61 | .\" TODO: Include order:
|
---|
| 62 | .\" For "..." files, first search "current" dir, then as <...> files.
|
---|
| 63 | .\" For <...> files, first search -I directories, then system directories.
|
---|
| 64 | .\"
|
---|
| 65 | The options are as follows:
|
---|
| 66 | .Bl -tag -width Ds
|
---|
| 67 | .It Fl ?
|
---|
| 68 | Show command line usage for
|
---|
| 69 | .Nm .
|
---|
| 70 | .It Fl C
|
---|
| 71 | Do not discard comments.
|
---|
| 72 | .It Fl D Ar macro[=value]
|
---|
| 73 | Fake a definition at the beginning by using
|
---|
| 74 | .Do #define
|
---|
| 75 | .Ar macro=value Dc .
|
---|
| 76 | If
|
---|
| 77 | .Ar value
|
---|
| 78 | is not set on command-line, then define it as 1.
|
---|
| 79 | .\" TODO: show example
|
---|
| 80 | .It Fl dM
|
---|
| 81 | Print list of
|
---|
| 82 | .Dq #define
|
---|
| 83 | statements to standard output for all defined macros other than
|
---|
| 84 | builtin macros (see below).
|
---|
| 85 | The normal results of preprocessing are not output.
|
---|
| 86 | .\" TODO this doesn't show predefined macros
|
---|
| 87 | .\" other -d options are ignored
|
---|
| 88 | .It Fl I Ar path
|
---|
| 89 | Add
|
---|
| 90 | .Ar path
|
---|
| 91 | to the list of directories containing needed header files.
|
---|
| 92 | This may be used to override system include directories
|
---|
| 93 | (see
|
---|
| 94 | .Fl S
|
---|
| 95 | option).
|
---|
| 96 | .Fl I
|
---|
| 97 | may be specified multiple times.
|
---|
| 98 | .It Fl i Ar file
|
---|
| 99 | Include a file at the beginning by using
|
---|
| 100 | .Do #include
|
---|
| 101 | .Ar file Dc .
|
---|
| 102 | .\" Note: I did not use the .In macro above
|
---|
| 103 | .It Fl M
|
---|
| 104 | Generate dependencies for
|
---|
| 105 | .Xr make 1 .
|
---|
| 106 | .\" TODO: explain and show example?
|
---|
| 107 | .It Fl P
|
---|
| 108 | Inhibit generation of line markers. This is sometimes useful when
|
---|
| 109 | running the preprocessor on something other than C code.
|
---|
| 110 | .It Fl S Ar path
|
---|
| 111 | Add
|
---|
| 112 | .Ar path
|
---|
| 113 | to the list of system directories containing needed header files.
|
---|
| 114 | The
|
---|
| 115 | .Fl S
|
---|
| 116 | option may be specified multiple times.
|
---|
| 117 | Note:
|
---|
| 118 | .Nm
|
---|
| 119 | does not have a default include directory defined.
|
---|
| 120 | .\" TODO: explain difference between -I and -S
|
---|
| 121 | .\" The directories listed by -I are searched first?
|
---|
| 122 | .It Fl t
|
---|
| 123 | Traditional cpp syntax.
|
---|
| 124 | Do not define the
|
---|
| 125 | .Dv __TIME__ ,
|
---|
| 126 | .Dv __DATE__ ,
|
---|
| 127 | .Dv __STDC__ ,
|
---|
| 128 | and
|
---|
| 129 | .Dv __STDC_VERSION__
|
---|
| 130 | macros.
|
---|
| 131 | .\"
|
---|
| 132 | .It Fl U Ar macro
|
---|
| 133 | Undefine a macro at the beginning by using
|
---|
| 134 | .Do #undef
|
---|
| 135 | .Ar macro Dc .
|
---|
| 136 | .It Fl V
|
---|
| 137 | Verbose debugging output.
|
---|
| 138 | .Fl V
|
---|
| 139 | can be repeated for further details.
|
---|
| 140 | .\" -V only available if cpp source built with CPP_DEBUG, which is the default.
|
---|
| 141 | .It Fl v
|
---|
| 142 | Display version.
|
---|
| 143 | .El
|
---|
| 144 | .Ss Builtin Macros
|
---|
| 145 | A few macros are interpreted inside the
|
---|
| 146 | .Nm cpp
|
---|
| 147 | program:
|
---|
| 148 | .Bl -diag
|
---|
| 149 | .It __DATE__
|
---|
| 150 | Expands to the date in abbreviated month, day, and year format from
|
---|
| 151 | .Xr ctime 3
|
---|
| 152 | in quotes.
|
---|
| 153 | .\" TODO: is that ctime(3) format output change according to locale?
|
---|
| 154 | .It __FILE__
|
---|
| 155 | Expands to the name of the current input file in quotes.
|
---|
| 156 | When read from standard input, it expands to
|
---|
| 157 | .Qq Aq stdin .
|
---|
| 158 | .It __LINE__
|
---|
| 159 | Expands to the line number of the current line containing the macro.
|
---|
| 160 | .It __STDC__
|
---|
| 161 | Expands to the constant 1.
|
---|
| 162 | This means the compiler conforms to
|
---|
| 163 | .St -isoC
|
---|
| 164 | .Po also known as
|
---|
| 165 | .Do C90 Dc Pc .
|
---|
| 166 | .It __STDC_VERSION__
|
---|
| 167 | Expands to
|
---|
| 168 | .Dq 199901L
|
---|
| 169 | which indicates that
|
---|
| 170 | .Nm
|
---|
| 171 | supports
|
---|
| 172 | .St -isoC-99
|
---|
| 173 | .Po commonly referred to as
|
---|
| 174 | .Do C99 Dc Pc .
|
---|
| 175 | .It __TIME__
|
---|
| 176 | Expands to the time in hour, minutes, and seconds from
|
---|
| 177 | .Xr ctime 3
|
---|
| 178 | in quotes.
|
---|
| 179 | .El
|
---|
| 180 | .Pp
|
---|
| 181 | Also see the
|
---|
| 182 | .Fl t
|
---|
| 183 | option.
|
---|
| 184 | .Sh EXIT STATUS
|
---|
| 185 | The
|
---|
| 186 | .Nm
|
---|
| 187 | utility exits with one of the following values:
|
---|
| 188 | .Bl -tag -width Ds
|
---|
| 189 | .It 0
|
---|
| 190 | Successfully finished.
|
---|
| 191 | .It 1
|
---|
| 192 | An error occurred.
|
---|
| 193 | .El
|
---|
| 194 | .Sh SEE ALSO
|
---|
| 195 | .Xr as 1 ,
|
---|
| 196 | .Xr ccom 1 ,
|
---|
| 197 | .Xr pcc 1
|
---|
| 198 | .\"
|
---|
| 199 | .Sh HISTORY
|
---|
| 200 | The
|
---|
| 201 | .Nm
|
---|
| 202 | command comes from the original Portable C Compiler by S. C. Johnson,
|
---|
| 203 | written in the late 70's.
|
---|
| 204 | The code originates from the V6 preprocessor with some additions
|
---|
| 205 | from V7 cpp and ansi/c99 support.
|
---|
| 206 | .Pp
|
---|
| 207 | A lot of the PCC code was rewritten by Anders Magnusson.
|
---|
| 208 | .Pp
|
---|
| 209 | This product includes software developed or owned by Caldera
|
---|
| 210 | International, Inc.
|
---|