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