Properly support -ansi.
[cparser] / cparser.1
1 .\" Please adjust this date whenever revising the manpage.
2 .Dd July 3, 2012
3 .Dt CPARSER 1
4 .Sh NAME
5 .Nm cparser
6 .Nd C compiler
7 .Sh SYNOPSIS
8 .Nm
9 .Op Fl c | S | E | -print-ast
10 .Op Fl -print-implicit-cast
11 .Op Fl -print-parenthesis
12 .Op Fl ansi
13 .Op Fl std= Ns Ar standard
14 .Op Fl - Ns Oo Cm no- Oc Ns Cm gcc
15 .Op Fl - Ns Oo Cm no- Oc Ns Cm ms
16 .Op Fl g
17 .Op Fl O Ns Ar level
18 .Op Fl W Ns Oo Cm no- Oc Ns Oo Cm error= Oc Ns Ar warning
19 .Op Fl w
20 .Op Fl I Ar dir
21 .Op Fl L Ar dir
22 .Op Fl D Ns Ar macro Ns Op Ar =defn
23 .Op Fl U Ns Ar macro
24 .Op Fl f Ar option
25 .Op Fl finput-charset= Ns Ar encoding
26 .Op Fl b Ar option
27 .Op Fl l Ar library
28 .Op Fl o Ar outfile
29 .Op Fl x Ar language
30 .Op Fl Wl, Ns Ar option
31 .Op Fl Wp, Ns Ar option
32 .Ar
33 .Sh DESCRIPTION
34 .Nm
35 is a C compiler, which can parse C90 and C99 as well as many GCC and some MSC extensions.
36 It also provides many useful analyses for warnings and generates concise messages in case of error.
37 It uses libFIRM for optimization and code generation.
38 The compiler driver is largely compatible with GCC.
39 .Sh OPTIONS
40 .Bl -tag
41 .It Fl c
42 Compile the input files to object files.
43 The default output filename is the input filename with the extension replaced by .o.
44 .It Fl S
45 Compile the input files to assembler.
46 The default output filename is the input filename with the extension replaced by .s.
47 .It Fl E
48 Preprocess the input file only.
49 By default the result is output to stdout.
50 .It Fl -print-ast
51 Output the abstract syntax tree of the parsed input file as C again.
52 .It Fl -print-implicit-cast
53 When using
54 .Fl -print-ast ,
55 show casts, which are inserted by the semantic checks.
56 .It Fl -print-parenthesis
57 When using
58 .Fl -print-ast ,
59 show all expressions fully parenthesized.
60 .It Fl ansi
61 Same as -std=c90 (for C) or -std=c++98 (for C++).
62 .It Fl std= Ns Ar standard
63 Select the language standard.
64 Supported values are:
65 .Bl -tag -compact -width "iso9899:1990"
66 .It Cm c89
67 .It Cm c90
68 .It Cm iso9899:1990
69 ISO C90
70 .It Cm gnu89
71 ISO C90 with GCC extensions
72 .It Cm c99
73 .It Cm iso9899:1999
74 ISO C99
75 .It Cm gnu99
76 ISO C99 with GCC extensions
77 .It Cm c++98
78 ISO C++ 1998.
79 Not supported yet.
80 .It Cm gnu++98
81 ISO C++ 1998 with GCC extensions.
82 Not supported yet.
83 .El
84 .It Fl - Ns Oo Cm no- Oc Ns Cm gcc
85 Disable/enable GCC extensions.
86 This switch supersedes
87 .Fl std .
88 .It Fl - Ns Oo Cm no- Oc Ns Cm ms
89 Disable/enable MSC extensions.
90 .It Fl g
91 When compiling C files, add debug information in
92 .Tn stabs
93 format.
94 .It Fl O Ns Ar level
95 .\" TODO expand
96 Select the optimization level.
97 Sensible values are between 0 and 4, inclusive.
98 .\" TODO expand
99 .It Fl W Ns Ar warning
100 Enable the specified warning.
101 .It Fl Wno- Ns Ar warning
102 Disable the specified warning.
103 .It Fl Werror= Ns Ar warning
104 Enable the specified warning and turn it into an error.
105 .It Fl Wno-error= Ns Ar warning
106 Force the specified warning to only be a warning, even in the presence of
107 .Fl Werror .
108 This neither enables nor disables the warning itself.
109 .It Fl Waddress
110 Warn about suspicious use of addresses, like using the address of a function or variable as boolean condition or comparing with the address of a string literal.
111 .It Fl Waggregate-return
112 Warn about defining or calling a function, which returns a struct or union by value.
113 .It Fl Wall
114 Activate most warnings.
115 In particular these are
116 .Fl Waddress ,
117 .Fl Wattribute ,
118 .Fl Wchar-subscripts ,
119 .Fl Wcomment ,
120 .Fl Wempty-statement ,
121 .Fl Wformat ,
122 .Fl Wimplicit-function-declaration ,
123 .Fl Wimplicit-int ,
124 .Fl Winit-self ,
125 .Fl Wmain ,
126 .Fl Wnonnull ,
127 .Fl Wparentheses ,
128 .Fl Wpointer-arith ,
129 .Fl Wredundant-decls ,
130 .Fl Wreturn-type ,
131 .Fl Wshadow-local ,
132 .Fl Wsign-compare ,
133 .Fl Wstrict-prototypes ,
134 .Fl Wswitch-enum ,
135 .Fl Wunknown-pragmas ,
136 .Fl Wunreachable-code ,
137 .Fl Wunused-function ,
138 .Fl Wunused-label ,
139 .Fl Wunused-parameter ,
140 .Fl Wunused-value ,
141 .Fl Wunused-variable .
142 .It Fl Wcast-qual
143 Warn whenever a pointer cast removes qualifiers from the pointed-to type, e.g. casting a const char* to char*.
144 .It Fl Wchar-subscripts
145 Warn about using an expression of type char as array subscript, e.g. char\ c; arr[c].
146 .It Fl Wdeclaration-after-statement
147 Warn about mixing declarations and statements, which is not allowed prior to C99.
148 .It Fl Wdiv-by-zero
149 Warn about compile-time integer division by zero.
150 .It Fl Wempty-statement
151 Warn about empty statements, i.e. statements which only consist of a single
152 .Sq \&; .
153 Use {} as replacement to avoid this warning.
154 .It Fl Werror
155 Treat warnings as errors, i.e. do not continue after parsing when a warning is encountered.
156 .It Fl Wextra
157 (Alias
158 .Fl W Ns )
159 Activate some more warnings.
160 In particular these are
161 .Fl Wempty-statement ,
162 .Fl Wshadow ,
163 .Fl Wunused-parameter ,
164 .Fl Wunused-value .
165 .It Fl Wfatal-errors
166 Immediately abort compilation when encountering an error.
167 .It Fl Wformat
168 Check format strings of char and wchar_t functions.
169 .It Fl Wimplicit
170 Activate
171 .Fl Wimplicit-function-declaration ,
172 .Fl Wimplicit-int .
173 .It Fl Wimplicit-function-declaration
174 Warn about calling a function without a prior declaration.
175 .It Fl Wimplicit-int
176 Warn about declarations whose declaration specifiers do not include a type specifier.
177 .It Fl Winit-self
178 Warn about uninitialized variables which are initialized with themselves.
179 .It Fl Wlong-long
180 Warn if the type
181 .Sq long long
182 is used.
183 .It Fl Wmain
184 Warn if the type of
185 .Sq main
186 is suspicious, i.e. if it is not a non-static function declared as either int\ main(void), int\ main(int,\ char**) or, as an extension, int\ main(int,\ char**,\ char**).
187 .It Fl Wmissing-declarations
188 Warn if a non-static function or a global variable without a storage class is defined without a prior declaration.
189 This is typically a sign of a missing #include or that the object should be static.
190 .It Fl Wmissing-noreturn
191 Warn about functions, which are candidates for the attribute
192 .Sq noreturn .
193 .It Fl Wmissing-prototypes
194 Warn if a global function is defined without a previous prototype declaration.
195 .It Fl Wmultichar
196 Warn if a multicharacter constant
197 .Pf ( Sq FOOF )
198 is used.
199 .It Fl Wnested-externs
200 Warn if an
201 .Sq extern
202 declaration is encountered within a function.
203 .It Fl Wparentheses
204 Warn if parentheses are omitted in certain contexts.
205 Warn if an assignment is used as condition, e.g. if\ (x\ =\ 23).
206 Warn if && without parentheses is used within ||, e.g. if\ (x\ ||\ y\ &&\ z).
207 Warn if it there may be confusion which
208 .Sq if Ns
209 -statement an
210 .Sq else Ns
211 -branch belongs to, e.g. if\ (x)\ if\ (y)\ {}\ else\ {}.
212 Warn if cascaded comparisons appear which do not have their mathematical meaning, e.g. if\ (23\ <=\ x\ <\ 42).
213 Warn if + or - is used as operand of << or >>, e.g. x\ +\ y\ <<\ z.
214 .It Fl Wredundant-decls
215 Warn about redundant declarations, i.e. multiple declarations of the same object or static forward declarations which have no use before their definition.
216 .It Fl Wshadow
217 Warn when a new declaration shadows another declaration with the same name in an outer scope.
218 .It Fl Wshadow-local
219 Like
220 .Fl Wshadow ,
221 but only warn if the shadowed declaration is not global, e.g. a local variable shadows a parameter or another local variable.
222 .It Fl Wunreachable-code
223 Warn when the compiler determines that a statement (or in some cases a part thereof) will never be executed.
224 .It Fl Wunused
225 Activate
226 .Fl Wunused-function ,
227 .Fl Wunused-label ,
228 .Fl Wunused-parameter ,
229 .Fl Wunused-value ,
230 .Fl Wunused-variable .
231 .It Fl Wunused-parameter
232 Warn when a parameter is never used or only ever read to calculate its own new value, e.g. x\ =\ x\ +\ 1.
233 .It Fl Wunused-variable
234 Warn when a variable is never used or only ever read to calculate its own new value, e.g. x\ =\ x\ +\ 1.
235 .It Fl w
236 Suppress all warnings.
237 .It Fl I Ar dir
238 Add the directory
239 .Ar dir
240 to the paths to be searched for include files.
241 .It Fl L Ar dir
242 Add the directory
243 .Ar dir
244 to the paths to be searched for libraries.
245 .It Fl D Ns Ar macro
246 Define the preprocessor macro
247 .Ar macro
248 which will expand to 1.
249 .It Fl D Ns Ar macro=defn
250 Define the preprocessor macro
251 .Ar macro
252 and set its expanded value to
253 .Ar defn .
254 .It Fl U Ns Ar macro
255 Undefine the preprocessor macro
256 .Ar macro .
257 .It Fl f Ar option
258 Set a frontend or optimizer option.
259 Use
260 .Fl fhelp
261 to get a list of supported optimizer options.
262 .It Fl f Ns Oo Cm no- Oc Ns Cm diagnostics-show-option
263 Show the switch, which controls a warning, after each warning.
264 Default is on.
265 .It Fl finput-charset= Ns Ar encoding
266 Select the encoding of the input.
267 Supported values are
268 .Cm ISO_8859-1:1987
269 (aliases
270 .Cm CP819 ,
271 .Cm IBM819 ,
272 .Cm ISO-8859-1 ,
273 .Cm ISO8859-1 ,
274 .Cm ISO_8859-1 ,
275 .Cm csISOLatin1 ,
276 .Cm iso-ir-100 ,
277 .Cm l1
278 and
279 .Cm latin1 Ns
280 ),
281 .Cm ISO-8859-15
282 (aliases
283 .Cm ISO8859-15 ,
284 .Cm ISO_8859-15
285 and
286 .Cm Latin-9 Ns
287 ),
288 .Cm windows-1252
289 (alias
290 .Cm cp1252 Ns
291 ) and
292 .Cm UTF-8
293 (default).
294 Case is ignored.
295 .It Fl f Ns Oo Cm no- Oc Ns Cm show-column
296 Show the column number in diagnostic messages.
297 .It Fl fsigned-char
298 Define
299 .Sq char
300 to have the same range, representation and behaviour as
301 .Sq signed char .
302 .It Fl funsigned-char
303 Define
304 .Sq char
305 to have the same range, representation and behaviour as
306 .Sq unsigned char .
307 .It Fl b Ar option
308 Set a backend option.
309 Use
310 .Fl bhelp
311 to get a list of supported options.
312 .It Fl l Ar library
313 Link with the specified library.
314 .It Fl o Ar outfile
315 Specify the output filename.
316 This is only valid when using a single input filename.
317 .Fl
318 as filename uses stdout for output.
319 .It Fl x Ar language
320 Overwrite the language auto-detection for the following filenames by the
321 specified
322 .Ar language .
323 Supported values are:
324 .Bl -tag -compact -width "assembler-with-cpp"
325 .It Cm assembler
326 Assembler file
327 .It Cm assembler-with-cpp
328 Assembler file, which needs to be preprocessed
329 .It Cm c
330 .It Cm c-header
331 C file
332 .It Cm c++
333 .It Cm c++-header
334 C++ file
335 .It Cm none
336 Revert to auto-detection
337 .El
338 .It Fl Wl, Ns Ar option
339 Pass
340 .Ar option
341 to the linker.
342 .It Fl Wp, Ns Ar option
343 Pass
344 .Ar option
345 to the preprocessor.
346 .El
347 .Sh SEE ALSO
348 .Xr gcc 1 ,
349 http://www.libfirm.org/
350 .Sh BUGS
351 Probably many - if you hit one, please report it.
352 .Pp
353 .Nm
354 needs to support more switches for better GCC compatibility.
355 .Pp
356 This manual page is incomplete.
357 .Sh AUTHORS
358 .An -nosplit
359 .Nm
360 was written by
361 .An Matthias Braun
362 .Aq matze@braunis.de ,
363 .An Christoph Mallon
364 .Aq christoph.mallon@gmx.de
365 and
366 .An Michael Beck .