<argchoice="opt"><option>file or path</option></arg>
<argchoice="plain"><option>...</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1id="description">
<title>DESCRIPTION</title>
<para>Cppcheck is a command-line tool that tries to detect bugs that your C/C++
compiler doesn't see. It is versatile, and can check non-standard code
including various compiler extensions, inline assembly code, etc.
Its internal preprocessor can handle includes, macros, and several
preprocessor commands. While Cppcheck is highly configurable,
you can start using it just by giving it a path to the source code.
</para>
</refsect1>
<refsect1id="options">
<title>OPTIONS</title>
<para>Analyze given C/C++ files for common errors.</para>
<variablelist>
<!-- Use the variablelist.term.separator and the
variablelist.term.break.after parameters to
control the term elements. -->
<varlistentry>
<term><option>--check-config</option></term>
<listitem>
<para>Check Cppcheck configuration. The normal code analysis is disabled by this flag.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--check-library</option></term>
<listitem>
<para>Show information messages when library files have incomplete info.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-D<id></option></term>
<listitem>
<para>By default Cppcheck checks all configurations. Use -D to limit the checking. When -D is used the checking is limited to the given configuration.
Example: -DDEBUG=1 -D__cplusplus</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-U<id></option></term>
<listitem>
<para>By default Cppcheck checks all configurations. Use '-U' to explicitly hide certain #ifdef <id> code paths from checking.
Example: '-UDEBUG'</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--enable=<id></option></term>
<listitem>
<para>Enable additional checks. The available ids are:
<glosslist>
<glossentry>
<glossterm>all</glossterm>
<glossdef>
<para>Enable all checks. It is recommended to only use
--enable=all when the whole program is scanned, because this
enables unusedFunction.</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>warning</glossterm>
<glossdef>
<para>Enable warning messages</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>style</glossterm>
<glossdef>
<para>Enable all coding style checks. All messages with the
severities 'style', 'performance' and 'portability' are
enabled.</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>performance</glossterm>
<glossdef>
<para>Enable performance messages</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>portability</glossterm>
<glossdef>
<para>Enable portability messages</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>information</glossterm>
<glossdef>
<para>Enable information messages</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>unusedFunction</glossterm>
<glossdef>
<para>Check for unused functions. It is recommend to only
enable this when the whole program is scanned</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>missingInclude</glossterm>
<glossdef>
<para>Warn if there are missing includes. For detailed information use --check-config</para>
</glossdef>
</glossentry>
</glosslist>
By default none of the additional checks are enabled. Several ids can be given if you separate them with commas, e.g. --enable=style,unusedFunction. See also --std
<para>Use relative paths in output. When given, <paths> are used as base. You can separate multiple paths by ';'. Otherwise path where source files are searched is used. E.g. if given value is test, when checking test/test.cpp, the path in output will be test.cpp instead of test/test.cpp. The feature uses string comparison to create relative paths, so using e.g. ~ for home folder does not work. It is currently only possible to apply the base paths to files that are on a lower level in the directory tree.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--report-progress</option></term>
<listitem>
<para>Report progress when checking a file.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--rule=<rule></option></term>
<listitem>
<para>Match regular expression to create your own checks. E.g. rule "/ 0" can be used to check division by zero. This command is only available if cppcheck was compiled with HAVE_RULES=yes.</para>
<para>Use given rule XML file. See https://sourceforge.net/projects/cppcheck/files/Articles/ for more info about the syntax. This command is only available if cppcheck was compiled with HAVE_RULES=yes.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--std=<id></option></term>
<listitem>
<para>Set standard. The available options are:
<glosslist>
<glossentry>
<glossterm>posix</glossterm>
<glossdef>
<para>POSIX compatible code</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>c89</glossterm>
<glossdef>
<para>C code is C89 compatible</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>c99</glossterm>
<glossdef>
<para>C code is C99 compatible</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>c11</glossterm>
<glossdef>
<para>C code is C11 compatible (default)</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>c++03</glossterm>
<glossdef>
<para>C++ code is C++03 compatible</para>
</glossdef>
</glossentry>
<glossentry>
<glossterm>c++11</glossterm>
<glossdef>
<para>C++ code is C++11 compatible (default)</para>
</glossdef>
</glossentry>
</glosslist>
Example to set more than one standards: 'cppcheck --std=c99 --std=posix file.cpp'
<para>Format the error messages. E.g. '{file}:{line},{severity},{id},{message}' or '{file}({line}):({severity}) {message}'. Pre-defined templates: gcc, vs</para>