'\" t
.\"     Title: CPPCHECK
.\"    Author: Reijo Tomperi <aggro80@users.sourceforge.net>
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 09/22/2023
.\"    Manual: cppcheck User Manual
.\"    Source: cppcheck
.\"  Language: English
.\"
.TH "CPPCHECK" "1" "09/22/2023" "cppcheck" "cppcheck User Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
cppcheck \- Tool for static C/C++ code analysis
.SH "SYNOPSIS"
.HP \w'\fBcppcheck\fR\ 'u
\fBcppcheck\fR [\fB\-\-check\-config\fR] [\fB\-\-check\-library\fR] [\fB\-D<id>\fR] [\fB\-U<id>\fR] [\fB\-\-disable=<id>\fR] [\fB\-\-enable=<id>\fR] [\fB\-\-error\-exitcode=<n>\fR] [\fB\-\-errorlist\fR] [\fB\-\-exitcode\-suppressions=<file>\fR] [\fB\-\-file\-list=<file>\fR] [\fB\-\-force\fR] [\fB\-\-help\fR] [\fB\-I<dir>\fR] [\fB\-\-includes\-file=<file>\fR] [\fB\-\-config\-exclude=<dir>\fR] [\fB\-\-config\-excludes\-file=<file>\fR] [\fB\-\-include=<file>\fR] [\fB\-i<dir>\fR] [\fB\-\-inconclusive\fR] [\fB\-\-inline\-suppr\fR] [\fB\-j<jobs>\fR] [\fB\-l<load>\fR] [\fB\-\-language=<language>\fR] [\fB\-\-library=<cfg>\fR] [\fB\-\-max\-configs=<limit>\fR] [\fB\-\-max\-ctu\-depth=<limit>\fR] [\fB\-\-platform=<type>\fR] [\fB\-\-quiet\fR] [\fB\-\-relative\-paths=<paths>\fR] [\fB\-\-report\-progress\fR] [\fB\-\-rule=<rule>\fR] [\fB\-\-rule\-file=<file>\fR] [\fB\-\-std=<id>\fR] [\fB\-\-suppress=<spec>\fR] [\fB\-\-suppressions\-list=<file>\fR] [\fB\-\-suppress\-xml=<\&.xml\ file>\fR] [\fB\-\-template=\*(Aq<text>\*(Aq\fR] [\fB\-\-verbose\fR] [\fB\-\-version\fR] [\fB\-\-xml\fR] [\fB\-\-xml\-version=<version>]\fR] [\fBfile\ or\ path\fR] \fB\&.\&.\&.\fR
.SH "DESCRIPTION"
.PP
Cppcheck is a command\-line tool that tries to detect bugs that your C/C++ compiler doesn\*(Aqt 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\&.
.SH "OPTIONS"
.PP
Analyze given C/C++ files for common errors\&.
.PP
\fB\-\-check\-config\fR
.RS 4
Check Cppcheck configuration\&. The normal code analysis is disabled by this flag\&.
.RE
.PP
\fB\-\-check\-library\fR
.RS 4
Show information messages when library files have incomplete info\&.
.RE
.PP
\fB\-D<id>\fR
.RS 4
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
.RE
.PP
\fB\-U<id>\fR
.RS 4
By default Cppcheck checks all configurations\&. Use \*(Aq\-U\*(Aq to explicitly hide certain #ifdef <id> code paths from checking\&. Example: \*(Aq\-UDEBUG\*(Aq
.RE
.PP
\fB\-\-disable=<id>\fR
.RS 4
Disable individual checks\&. Please refer to the documentation of \-\-enable=<id> for further details\&.
.RE
.PP
\fB\-\-enable=<id>\fR
.RS 4
Enable additional checks\&. The available ids are:
.PP
all
.RS 4
Enable all checks\&. It is recommended to only use \-\-enable=all when the whole program is scanned, because this enables unusedFunction\&.
.RE
.PP
warning
.RS 4
Enable warning messages
.RE
.PP
style
.RS 4
Enable all coding style checks\&. All messages with the severities \*(Aqstyle\*(Aq, \*(Aqperformance\*(Aq and \*(Aqportability\*(Aq are enabled\&.
.RE
.PP
performance
.RS 4
Enable performance messages
.RE
.PP
portability
.RS 4
Enable portability messages
.RE
.PP
information
.RS 4
Enable information messages
.RE
.PP
unusedFunction
.RS 4
Check for unused functions\&. It is recommend to only enable this when the whole program is scanned
.RE
.PP
missingInclude
.RS 4
Warn if there are missing includes
.RE
.sp
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
.RE
.PP
\fB\-\-error\-exitcode=<n>\fR
.RS 4
If errors are found, integer <n> is returned instead of default 0\&. EXIT_FAILURE is returned if arguments are not valid or if no input files are provided\&. Note that your operating system can modify this value, e\&.g\&. 256 can become 0\&.
.RE
.PP
\fB\-\-errorlist\fR
.RS 4
Print a list of all possible error messages in XML format\&.
.RE
.PP
\fB\-\-exitcode\-suppressions=<file>\fR
.RS 4
Used when certain messages should be displayed but should not cause a non\-zero exitcode\&.
.RE
.PP
\fB\-\-file\-list=<file>\fR
.RS 4
Specify the files to check in a text file\&. One filename per line\&. When file is \-, the file list will be read from standard input\&.
.RE
.PP
\fB\-f\fR, \fB\-\-force\fR
.RS 4
Force checking of files that have a lot of configurations\&. Error is printed if such a file is found so there is no reason to use this by default\&. If used together with \-\-max\-configs=, the last option is the one that is effective\&.
.RE
.PP
\fB\-h\fR, \fB\-\-help\fR
.RS 4
Print help text\&.
.RE
.PP
\fB\-I <dir>\fR
.RS 4
Give path to search for include files\&. Give several \-I parameters to give several paths\&. First given path is searched for contained header files first\&. If paths are relative to source files, this is not needed\&.
.RE
.PP
\fB\-\-includes\-file=<file>\fR
.RS 4
Specify directory paths to search for included header files in a text file\&. Add one include path per line\&. First given path is searched for contained header files first\&. If paths are relative to source files, this is not needed\&.
.RE
.PP
\fB\-\-config\-exclude=<dir>\fR
.RS 4
Path (prefix) to be excluded from configuration checking\&. Preprocessor configurations defined in headers (but not sources) matching the prefix will not be considered for evaluation of configuration alternatives\&.
.RE
.PP
\fB\-\-config\-exclude\-file=<file>\fR
.RS 4
A file that contains a list of config\-excludes\&.
.RE
.PP
\fB\-\-include=<file>\fR
.RS 4
Force inclusion of a file before the checked file\&. Can be used for example when checking the Linux kernel, where autoconf\&.h needs to be included for every file compiled\&. Works the same way as the GCC \-include option\&.
.RE
.PP
\fB\-i <dir>\fR
.RS 4
Give path to ignore\&. Give several \-i parameters to ignore several paths\&. Give directory name or filename with path as parameter\&. Directory name is matched to all parts of the path\&.
.RE
.PP
\fB\-\-inconclusive\fR
.RS 4
Allow that Cppcheck reports even though the analysis is inconclusive\&. There are false positives with this option\&. Each result must be carefully investigated before you know if it is good or bad\&.
.RE
.PP
\fB\-\-inline\-suppr\fR
.RS 4
Enable inline suppressions\&. Use them by placing comments in the form: // cppcheck\-suppress memleak before the line to suppress\&.
.RE
.PP
\fB\-j <jobs>\fR
.RS 4
Start <jobs> threads to do the checking work\&.
.RE
.PP
\fB\-l <load>\fR
.RS 4
Specifies that no new threads should be started if there are other threads running and the load average is at least <load> (ignored on non UNIX\-like systems)
.RE
.PP
\fB\-\-language=<language>\fR
.RS 4
Forces cppcheck to check all files as the given language\&. Valid values are: c, c++
.RE
.PP
\fB\-\-library=<cfg>\fR
.RS 4
Use library configuration\&.
.RE
.PP
\fB\-\-max\-configs=<limit>\fR
.RS 4
Maximum number of configurations to check in a file before skipping it\&. Default is 12\&. If used together with \-\-force, the last option is the one that is effective\&.
.RE
.PP
\fB\-\-max\-ctu\-depth=<limit>\fR
.RS 4
Maximum depth in whole program analysis\&. Default is 2\&.
.RE
.PP
\fB\-\-platform=<type>\fR
.RS 4
Specifies platform specific types and sizes\&.The available platforms are:
.PP
unix32
.RS 4
32 bit unix variant
.RE
.PP
unix64
.RS 4
64 bit unix variant
.RE
.PP
win32A
.RS 4
32 bit Windows ASCII character encoding
.RE
.PP
win32W
.RS 4
32 bit Windows UNICODE character encoding
.RE
.PP
win64
.RS 4
64 bit Windows
.RE
.sp
By default the platform which was used to compile Cppcheck is used\&.
.RE
.PP
\fB\-q\fR, \fB\-\-quiet\fR
.RS 4
Only print something when there is an error\&.
.RE
.PP
\fB\-rp\fR, \fB\-rp=<paths>\fR, \fB\-\-relative\-paths;\fR, \fB\-\-relative\-paths=<paths>\fR
.RS 4
Use relative paths in output\&. When given, <paths> are used as base\&. You can separate multiple paths by \*(Aq;\*(Aq\&. 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\&.
.RE
.PP
\fB\-\-report\-progress\fR
.RS 4
Report progress when checking a file\&.
.RE
.PP
\fB\-\-rule=<rule>\fR
.RS 4
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\&.
.RE
.PP
\fB\-\-rule\-file=<file>\fR
.RS 4
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\&.
.RE
.PP
\fB\-\-std=<id>\fR
.RS 4
Set standard\&. The available options are:
.PP
c89
.RS 4
C code is C89 compatible
.RE
.PP
c99
.RS 4
C code is C99 compatible
.RE
.PP
c11
.RS 4
C code is C11 compatible (default)
.RE
.PP
c++03
.RS 4
C++ code is C++03 compatible
.RE
.PP
c++11
.RS 4
C++ code is C++11 compatible (default)
.RE
.sp
.RE
.PP
\fB\-\-suppress=<spec>\fR
.RS 4
Suppress a specific warning\&. The format of <spec> is: [error id]:[filename]:[line]\&. The [filename] and [line] are optional\&. [error id] may be * to suppress all warnings (for a specified file or files)\&. [filename] may contain the wildcard characters * or ?\&.
.RE
.PP
\fB\-\-suppressions\-list=<file>\fR
.RS 4
Suppress warnings listed in the file\&. Each suppression is in the format of <spec> above\&.
.RE
.PP
\fB\-\-suppress\-xml=<\&.xml file>\fR
.RS 4
Use suppressions defined in xml as described in the manual
.RE
.PP
\fB\-\-template=\*(Aq<text>\*(Aq\fR
.RS 4
Format the error messages\&. E\&.g\&. \*(Aq{file}:{line},{severity},{id},{message}\*(Aq or \*(Aq{file}({line}):({severity}) {message}\*(Aq\&. Pre\-defined templates: gcc, vs
.RE
.PP
\fB\-v\fR, \fB\-\-verbose\fR
.RS 4
More detailed error reports
.RE
.PP
\fB\-\-version\fR
.RS 4
Print out version information
.RE
.PP
\fB\-\-xml\fR
.RS 4
Write results in XML to error stream
.RE
.PP
\fB\-\-xml\-version=<version>\fR
.RS 4
Select the XML file version\&. Also implies \-\-xml\&. Currently only version 2 is available\&. The default version is 2\&.
.RE
.SH "AUTHOR"
.PP
The program was written by Daniel Marjam\(:aki and Cppcheck team\&. See AUTHORS file for list of team members\&.
.SH "SEE ALSO"
.PP
Full list of features: https://sourceforge\&.net/p/cppcheck/wiki/Home/
.SH "AUTHOR"
.PP
\fBReijo Tomperi\fR <\&aggro80@users\&.sourceforge\&.net\&>
.RS 4
Wrote this manpage for the Debian system\&.
.RE
.SH "COPYRIGHT"
.br
Copyright \(co 2009 - 2016 Reijo Tomperi
.br
.PP
This manual page was written for the Debian system (but may be used by others)\&.
.PP
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 or (at your option) any later version published by the Free Software Foundation\&.
.PP
On Debian systems, the complete text of the GNU General Public License can be found in
/usr/share/common\-licenses/GPL\-3\&.
.sp
