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