CPARSER(1)

NAME
cparser - C compiler

SYNOPSIS
cparser [-c | -S | -E | --print-ast | -dumpmachine] [--print-implicit-cast] [--print-parenthesis] [- [no-]integrated-cpp] [-target architecture-vendor-system] [-ansi] [-std=standard] [--[no-]gcc] [--[no-]ms] [-g[level]] [-O[level]] [-W[[no-][error=]warning]] [-w] [-Idir] [-Ldir] [-Dmacro[=defn]] [-Umacro] [-foption] [-finput-charset=encoding] [-moption] [-llibrary] [-ooutfile] [-xlanguage] [-Wl,option] [-Wp,option] [--sysroot=dir] [-isysroot dir] file ...

DESCRIPTION
cparser is a C compiler, which can parse C90 and C99 as well as many GCC and some MSC extensions. It also provides many useful analyses for warnings and generates concise messages in case of error. It uses libFIRM for optimization and code generation. The compiler driver is largely compatible with GCC.

OPTIONS

-c  Compile the input files to object files. The default output filename is the input filename with the extension replaced by ‘.o’.

-S  Compile the input files to assembler. The default output filename is the input filename with the extension replaced by ‘.s’.

-E  Preprocess the input file only. By default the result is output to stdout.

--print-ast
    Output the abstract syntax tree of the parsed input file as C again.

-dumpmachine
    Print the default target triple or the current target triple selected by -target.

--print-implicit-cast
    When using --print-ast, show casts, which are inserted by the semantic checks.

--print-parenthesis
    When using --print-ast, show all expressions fully parenthesized.

- [no-]integrated-cpp
    Use the integrated preprocessor instead of an external one. This is the default if no -target is specified. Otherwise the external preprocessor architecture-vendor-system-gcc is used.

-target architecture[[-vendor]-system]
    Set target, for which code is generated. The default target triple is determined by the host when building cparser. Supported architectures are:
    -   amd64, x86_64
    -   arm
    -   i386, i486, i586, i686, i787
    -   mips
    -   riscv32
    -   sparc
    Supported vendors are:
    -   leon (for sparc)
    -   unknown (default)
    Supported systems are:
    -   *bsd*
    -   darwin*
    -   elf, irtss, octopos, unknown (default)
    -   freebsd*
    -   *linux*
    -   midipix*
    -   mingw*

-ansi
    Same as -std=c90 (for C) or -std=c++98 (for C++).

-std=standard
    Select the language standard. Supported values are:
    c89
    c90
    iso9899:1990
        ISO C90
    gnu89
        ISO C90 with GCC extensions
    c99
    iso9899:1999
        ISO C99
    gnu99
        ISO C99 with GCC extensions
    c11
    iso9899:2011
        ISO C11
    gnu11
        ISO C11 with GCC extensions
    c++98
        ISO C++ 1998. Not supported yet.
    gnu++98
        ISO C++ 1998 with GCC extensions. Not supported yet.

--[no-]gcc
    Enable GCC extensions. This switch supersedes -std. The default depends on -std: On for gnu*, off otherwise.

--[no-]ms
    Enable MSC extensions. Default is off.

-g[level]
    When compiling C files, add DWARF debug information.

-O[level]
    Select the optimization level. Sensible values are fast, g, s, z and 0 till 4, inclusive. If level is not given, 1 is assumed. Default is 0.

-W[no-]warning
    Enable the specified warning.

-Werror=warning
    Enable the specified warning and turn it into an error, even in the presence of -Wno-error.

-Wno-error=warning
    Force the specified warning to only be a warning, even in the presence of -Werror. This neither enables nor disables the warning itself.

-Waddress
    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.

-Waggregate-return
    Warn about defining or calling a function, which returns a struct or union by value.

-Wall
    Activate most warnings. In particular these are -Waddress, -Wattribute, -Wchar-subscripts, -Wcomment, -Wempty-statement, -Wformat, -Wimplicit-function-declaration, -Wimplicit-int, -Winit-self, -Wmain, -Wnonnull, -Wparentheses-assignment, -Wparentheses-comparison, -Wparentheses-else, -Wparentheses-logical, -Wparentheses-shift, -Wpointer-arith, -Wredundant-decls, -Wreturn-type, -Wshadow-local, -Wsign-compare, -Wstrict-prototypes, -Wswitch-enum, -Wunknown-pragmas, -Wunreachable-code, -Wunused-function, -Wunused-label, -Wunused-parameter, -Wunused-value, -Wunused-variable.

-Wcast-qual
    Warn whenever a pointer cast removes qualifiers from the pointed-to type, e.g. casting a ‘const char*’ to ‘char*’.

-Wchar-subscripts
    Warn about using an expression of type char as array subscript, e.g. ‘char c; arr[c]’.

-Wcpp
    Show warning messages emitted by ‘#warning’ directives. Default is on.

-Wdeclaration-after-label
    Warn when a declaration is found right after a label, which is not allowed in C. This option has no effect for C++, which allows this. Default is on as error.

-Wdeclaration-after-statement
    Warn about mixing declarations and statements, which is not allowed prior to C99.

-Wdiv-by-zero
    Warn about compile-time integer division by zero.

-Wempty-statement
    Warn about empty statements, i.e. statements which only consist of a single ‘’;. Use ‘{}’ as replacement to avoid this warning.

-Werror
    Treat warnings as errors, i.e. do not continue after parsing when a warning is encountered.

-Wextra, -W
    Activate some more warnings. In particular these are -Wempty-statement, -Wshadow, -Wunused-parameter, -Wunused-value.

-Wfatal-errors
    Immediately abort compilation when encountering an error.

-Wformat
    Check format strings of char and wchar_t functions.

-Wimplicit
    Activate -Wimplicit-function-declaration, -Wimplicit-int.

-Wimplicit-function-declaration
    Warn about calling a function without a prior declaration.

-Wimplicit-int
    Warn about declarations whose declaration specifiers do not include a type specifier.

-Winit-self
    Warn about uninitialized variables which are initialized with themselves.

-Wlabel-at-end-of-block
    Warn when a label is found right before the closing brace of a compound statement, which is not allowed in C. Default is on as error.

-Wlong-long
    Warn if the type ‘long long’ is used.

-Wmain
    Warn if the type of ‘main’ is suspicious. It should be a non-static function declared as either ‘int main(void)’, ‘int main(int, char**)’ or, as an extension, ‘int main(int, char**, char**)’.

-Wmissing-declarations
    Warn if a non-static function or a global variable without a storage class is defined without a prior declaration. This is typically a sign of a missing #include or that the object should be static.

-Wmissing-noreturn
    Warn about functions, which are candidates for the attribute ‘noreturn’.

-Wmissing-prototypes
    Warn if a global function is defined without a previous prototype declaration.

-Wmultichar
    Warn if a multicharacter constant ('FOOF') is used.

-Wnested-externs
    Warn if an ‘extern’ declaration is encountered within a function.

-Wparentheses
    Warn if parentheses or braces are omitted in certain contexts. Activate -Wparentheses-assignment, -Wparentheses-comparison, -Wparentheses-else, -Wparentheses-logical, -Wparentheses-shift.

-Wparentheses-assignment
    Warn if an assignment is used as condition, e.g. ‘if (x = 23)’. Default is off.

-Wparentheses-comparison
    Warn if cascaded comparisons appear which do not have their mathematical meaning, e.g. ‘if (23 <= x < 42)’. Default is off.

-Wparentheses-else
    Warn if it there may be confusion which ‘if’-statement an ‘else’-branch belongs to, e.g. ‘if (x) if (y) {} else {}’. Default is off.

-Wparentheses-logical
    Warn if ‘&&’ without parentheses is used within ‘||’, e.g. ‘if (x || y && z)’. Default is off.

-Wparentheses-shift
    Warn if ‘+’ or ‘-’ is used as operand of ‘<<’ or ‘>>’, ‘e.g. x + y << z’. Default is off.

-Wredundant-decls
    Warn about redundant declarations, i.e. multiple declarations of the same object or static forward declarations which have no use before their definition.

-Wreturn-local-addr
    Warn about returning a pointer (or in C++, a reference) to a variable that goes out of scope after the function returns.

-Wshadow
    Warn when a new declaration shadows another declaration with the same name in an outer scope.

-Wshadow-local
    Like -Wshadow, but only warn if the shadowed declaration is not global, e.g. a local variable shadows a parameter or another local variable.

-Wsystem
    Show warnings in system headers. By default, no warnings in system headers are shown.

-Wunreachable-code
    Warn when the compiler determines that a statement (or in some cases a part thereof) will never be executed. Enabled by default.

-Wunused
    Activate -Wunused-function, -Wunused-label, -Wunused-parameter, -Wunused-value, -Wunused-variable.

-Wunused-label
    Warn whenever a label is declared but not used. Enabled by default.

-Wunused-function
    Warn whenever a static function is declared but not defined or a non-inline static function is unused. To suppress this warning, cast the function to ‘void’, e.g. ‘(void)fun’. Enabled by default.

-Wunused-parameter
    Warn when a parameter is never used or only ever read to calculate its own new value, e.g. ‘x = x + 1’. To suppress this warning, cast the parameter to ‘void’, e.g. ‘(void)x’. Enabled by default.

-Wunused-value
    Warn whenever a statement computes a result that is explicitly not used. To suppress this warning, cast the expression to ‘void’, e.g. ‘(void)(x + 1)’. Enabled by default.

-Wunused-variable
    Warn when a variable is never used or only ever read to calculate its own new value, e.g. ‘x = x + 1’. To suppress this warning, cast the variable to ‘void’, e.g. ‘(void)x’. Enabled by default.

-w  Suppress all warnings.

-Idir, -I dir
    Add the directory dir to the paths to be searched for include files.

-Ldir, -L dir
    Add the directory dir to the paths to be searched for libraries.

-Dmacro[=defn], -D macro[=defn]
    Define the preprocessor macro macro and set its expanded value to defn. If =defn is not given, the macro will expand to ‘1’.

-Umacro, -U macro
    Undefine the preprocessor macro macro.

-foption
    Set a frontend or optimizer option. Use -fhelp to get a list of supported optimizer options.

-f[no-]diagnostics-show-option
    Show the switch, which controls the warning, after each warning. Default is on.

-finput-charset=encoding
    Select the encoding of the input. Case is ignored. Supported values are:
    ISO_8859-1:1987
        aliases CP819, IBM819, ISO-8859-1, ISO8859-1, ISO_8859-1, csISOLatin1, iso-ir-100, l1 and latin1
    ISO-8859-15
        aliases ISO8859-15, ISO_8859-15 and Latin-9
    windows-1252
        alias cp1252
    UTF-8
        default

-f[no-]show-column
    Show the column number in diagnostic messages.

-fsigned-char
    Define ‘char’ to have the same range, representation and behaviour as ‘signed char’.

-funsigned-char
    Define ‘char’ to have the same range, representation and behaviour as ‘unsigned char’.

-moption
    Set a backend option. Use -mhelp to get a list of supported options.

-llibrary, -l library
    Link with the specified library.

-ooutfile, -o outfile
    Specify the output filename. This is only valid when using a single input filename. - as outfile uses stdout for output.

-xlanguage, -x language
    Overwrite the language auto-detection for the following filenames by the specified language. Supported values are:
    assembler
        Assembler file
    assembler-with-cpp
        Assembler file, which needs to be preprocessed
    c
    c-header
        C file
    c++
    c++-header
        C++ file
    none
        Revert to auto-detection

-Wl,option
    Pass option to the linker.

-Wp,option
    Pass option to the preprocessor.

--sysroot=dir, --sysroot dir
    Use dir 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 ‘=’. For include paths this option is superseded by -isysroot. By default no prefix is used and ‘=’ is not replaced.

-isysrootdir, -isysroot dir
    Use dir as prefix for all implicit include paths of the compiler driver as well as for all include paths, which start with ‘=’. this supersedes --sysroot. By default no prefix is used and ‘=’ is not replaced.

SEE ALSO
gcc(1), http://www.libfirm.org/

BUGS
Probably many - if you hit one, please report it.

cparser needs to support more switches for better GCC compatibility.

This manual page is incomplete.

AUTHORS
-nosplit cparser was written by Matthias Braun <matze@braunis.de>, Christoph Mallon <christoph.mallon@gmx.de> and Michael Beck.