| 1 |
.\" $Id: cpp.1,v 1.17 2013/02/26 19:27:38 plunky Exp $ |
| 2 |
.\" |
| 3 |
.\" Copyright (c) 2007 Jeremy C. Reed <[email protected]> |
| 4 |
.\" |
| 5 |
.\" Permission to use, copy, modify, and/or distribute this software for any |
| 6 |
.\" purpose with or without fee is hereby granted, provided that the above |
| 7 |
.\" copyright notice and this permission notice appear in all copies. |
| 8 |
.\" |
| 9 |
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR AND CONTRIBUTORS DISCLAIM |
| 10 |
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 |
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHOR AND |
| 12 |
.\" CONTRIBUTORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 |
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 |
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS |
| 15 |
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
| 16 |
.\" THIS SOFTWARE. |
| 17 |
.\" |
| 18 |
.Dd February 26, 2013 |
| 19 |
.Dt CPP 1 |
| 20 |
.Os |
| 21 |
.Sh NAME |
| 22 |
.Nm cpp |
| 23 |
.Nd C preprocessor |
| 24 |
.Sh SYNOPSIS |
| 25 |
.Nm |
| 26 |
.Op Fl ACEMPtVv |
| 27 |
.Op Fl D Ar macro Ns Oo = Ns Ar value Oc |
| 28 |
.Op Fl d Ar flags |
| 29 |
.Op Fl I Ar path |
| 30 |
.Op Fl i Ar file |
| 31 |
.Op Fl S Ar path |
| 32 |
.Op Fl U Ar macro |
| 33 |
.Op Ar infile | - |
| 34 |
.Op Ar outfile |
| 35 |
.Sh DESCRIPTION |
| 36 |
The |
| 37 |
.Nm |
| 38 |
utility is a macro preprocessor used by the |
| 39 |
.Xr pcc 1 |
| 40 |
compiler. |
| 41 |
It is mainly used to include header files, |
| 42 |
expand macro definitions, |
| 43 |
discard comments, |
| 44 |
and perform conditional compilation. |
| 45 |
.Nm |
| 46 |
is written to comply with the |
| 47 |
.St -isoC-99 |
| 48 |
specification. |
| 49 |
.Pp |
| 50 |
The |
| 51 |
.Ar infile |
| 52 |
input file is optional. |
| 53 |
If not provided or the file name is |
| 54 |
.Qq - |
| 55 |
(dash), |
| 56 |
.Nm |
| 57 |
reads its initial file from standard input. |
| 58 |
The |
| 59 |
.Ar outfile |
| 60 |
output file is also optional, with output written to standard |
| 61 |
output if not provided. |
| 62 |
.Pp |
| 63 |
The options are as follows: |
| 64 |
.Bl -tag -width Ds |
| 65 |
.It Fl A |
| 66 |
For assembler-with-cpp input: treat non-directive lines starting |
| 67 |
with a # as comments. |
| 68 |
.It Fl C |
| 69 |
Do not discard comments. |
| 70 |
.It Fl D Ar macro Ns Oo = Ns Ar value Oc |
| 71 |
Create a macro definition before processing any input, as if a |
| 72 |
.Lp |
| 73 |
.Dl #define Ar macro Ar value |
| 74 |
.Lp |
| 75 |
directive had appeared in the source. |
| 76 |
If |
| 77 |
.Ar value |
| 78 |
is not set on the command-line, then a value of 1 is used. |
| 79 |
.It Fl d Ar flags |
| 80 |
Modify output according to |
| 81 |
.Ar flags , |
| 82 |
which can be a list of character flags. |
| 83 |
The following flags are currently supported: |
| 84 |
.Bl -tag -width ".Sy M" |
| 85 |
.It Sy M |
| 86 |
Do not process any input, but output a list of |
| 87 |
.Dq #define |
| 88 |
statements for all defined macros other than builtin macros |
| 89 |
.Pq see below . |
| 90 |
.El |
| 91 |
.Lp |
| 92 |
any unknown flags are ignored. |
| 93 |
.It Fl E |
| 94 |
Modify the exit code, if there were any warnings. |
| 95 |
.It Fl I Ar path |
| 96 |
Add |
| 97 |
.Ar path |
| 98 |
to the list of directories searched by the |
| 99 |
.Dq #include |
| 100 |
directive. |
| 101 |
This may be used to override system include directories |
| 102 |
.Pq see Fl S No option . |
| 103 |
.Fl I |
| 104 |
may be specified multiple times and is cumulative. |
| 105 |
.It Fl i Ar file |
| 106 |
Include a file before processing any input, as if a |
| 107 |
.Lp |
| 108 |
.Dl #include Qo Ar file Qc |
| 109 |
.Lp |
| 110 |
directive had appeared in the source. |
| 111 |
.Fl i |
| 112 |
may be specified multiple times to include several files. |
| 113 |
.It Fl M |
| 114 |
Instead of producing a processed C code file, output a list |
| 115 |
of dependencies for |
| 116 |
.Xr make 1 , |
| 117 |
detailing the files that need to be processed when compiling |
| 118 |
the input. |
| 119 |
.It Fl P |
| 120 |
Inhibit generation of line markers. This is sometimes useful when |
| 121 |
running the preprocessor on something other than C code. |
| 122 |
.It Fl S Ar path |
| 123 |
Add |
| 124 |
.Ar path |
| 125 |
to the list of system directories searched by the |
| 126 |
.Dq #include |
| 127 |
directive. |
| 128 |
The |
| 129 |
.Fl S |
| 130 |
option may be specified multiple times and is cumulative. |
| 131 |
.It Fl t |
| 132 |
Traditional cpp syntax. |
| 133 |
Do not define the |
| 134 |
.Dv __TIME__ , |
| 135 |
.Dv __DATE__ , |
| 136 |
.Dv __STDC__ , |
| 137 |
and |
| 138 |
.Dv __STDC_VERSION__ |
| 139 |
macros. |
| 140 |
.It Fl U Ar macro |
| 141 |
Undefine a macro before processing any input, as if a |
| 142 |
.Lp |
| 143 |
.Dl #undef Ar macro |
| 144 |
.Lp |
| 145 |
directive had appeared in the source. |
| 146 |
.It Fl V |
| 147 |
Verbose debugging output. |
| 148 |
.Fl V |
| 149 |
can be repeated for greater detail. |
| 150 |
.Po |
| 151 |
This is only available if the |
| 152 |
.Nm |
| 153 |
program was built with |
| 154 |
.Dv PCC_DEBUG |
| 155 |
defined, which is the default |
| 156 |
.Pc . |
| 157 |
.It Fl v |
| 158 |
Display version. |
| 159 |
.El |
| 160 |
.Pp |
| 161 |
The |
| 162 |
.Fl D , |
| 163 |
.Fl i |
| 164 |
and |
| 165 |
.Fl U |
| 166 |
options are processed in the order that they appear on the command |
| 167 |
line, before any input is read but after the command line options |
| 168 |
have been scanned. |
| 169 |
.Pp |
| 170 |
Files referenced by the |
| 171 |
.Dq #include |
| 172 |
directive as |
| 173 |
.Qq ... , |
| 174 |
are first looked for in the current directory, then as per |
| 175 |
.Aq ... |
| 176 |
files, which are first looked for in the list of |
| 177 |
directories provided by any |
| 178 |
.Fl I |
| 179 |
options, then in the list of system directories provided by any |
| 180 |
.Fl S |
| 181 |
options. |
| 182 |
Note that |
| 183 |
.Nm |
| 184 |
does not define any include directories by default; if no |
| 185 |
.Fl I |
| 186 |
or |
| 187 |
.Fl S |
| 188 |
options are given, then only the current directory will be |
| 189 |
searched and no system files will be found. |
| 190 |
.Ss Builtin Macros |
| 191 |
A few macros are interpreted inside the |
| 192 |
.Nm cpp |
| 193 |
program: |
| 194 |
.Bl -diag |
| 195 |
.It __DATE__ |
| 196 |
Expands to a quoted string literal containing the date in the form |
| 197 |
.Qq Mmm dd yyyy , |
| 198 |
where the names of the months are the same as those generated by the |
| 199 |
.Xr asctime 3 |
| 200 |
function, and the first character of dd is a space character if |
| 201 |
the value is less than 10. |
| 202 |
.It __FILE__ |
| 203 |
Expands to a quoted string literal containing the presumed name of |
| 204 |
the current source file. |
| 205 |
When reading source from standard input, it expands to |
| 206 |
.Qq Aq stdin . |
| 207 |
.It __LINE__ |
| 208 |
Expands to an integer constant representing the presumed line number |
| 209 |
of the source line containing the macro. |
| 210 |
.It __STDC__ |
| 211 |
Expands to the integer constant |
| 212 |
.Dq 1 , |
| 213 |
meaning that the compiler conforms to |
| 214 |
.St -isoC . |
| 215 |
.It __STDC_VERSION__ |
| 216 |
Expands to the integer constant |
| 217 |
.Dq 199901L , |
| 218 |
indicating that |
| 219 |
.Nm |
| 220 |
conforms to |
| 221 |
.St -isoC-99 . |
| 222 |
.It __TIME__ |
| 223 |
Expands to a quoted string literal containing the time in the form |
| 224 |
.Qq hh:mm:ss |
| 225 |
as generated by the |
| 226 |
.Xr asctime 3 |
| 227 |
function. |
| 228 |
.El |
| 229 |
.Pp |
| 230 |
Also see the |
| 231 |
.Fl t |
| 232 |
option. |
| 233 |
.Sh EXIT STATUS |
| 234 |
The |
| 235 |
.Nm |
| 236 |
utility exits with one of the following values: |
| 237 |
.Lp |
| 238 |
.Bl -tag -width Ds -offset indent -compact |
| 239 |
.It 0 |
| 240 |
Successfully finished. |
| 241 |
.It 1 |
| 242 |
An error occurred. |
| 243 |
.It 2 |
| 244 |
The |
| 245 |
.Fl E |
| 246 |
option was given, and warnings were issued. |
| 247 |
.El |
| 248 |
.Sh SEE ALSO |
| 249 |
.Xr as 1 , |
| 250 |
.Xr ccom 1 , |
| 251 |
.Xr make 1 , |
| 252 |
.Xr pcc 1 , |
| 253 |
.Xr asctime 3 |
| 254 |
.Sh HISTORY |
| 255 |
The |
| 256 |
.Nm |
| 257 |
command comes from the original Portable C Compiler by |
| 258 |
.An "S. C. Johnson" , |
| 259 |
written in the late 70's. |
| 260 |
The code originates from the V6 preprocessor with some additions |
| 261 |
from V7 cpp and ansi/c99 support. |
| 262 |
.Pp |
| 263 |
A lot of the PCC code was rewritten by |
| 264 |
.An "Anders Magnusson" . |
| 265 |
.Pp |
| 266 |
This product includes software developed or owned by Caldera |
| 267 |
International, Inc. |