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