1CPPCHECK(1)                  cppcheck User Manual                  CPPCHECK(1)
2
3
4

NAME

6       cppcheck - Tool for static C/C++ code analysis
7

SYNOPSIS

9       cppcheck [--check-config] [--check-library] [-D<id>] [-U<id>]
10                [--disable=<id>] [--enable=<id>] [--error-exitcode=<n>]
11                [--errorlist] [--exitcode-suppressions=<file>]
12                [--file-list=<file>] [--force] [--help] [-I<dir>]
13                [--includes-file=<file>] [--config-exclude=<dir>]
14                [--config-excludes-file=<file>] [--include=<file>] [-i<dir>]
15                [--inconclusive] [--inline-suppr] [-j<jobs>] [-l<load>]
16                [--language=<language>] [--library=<cfg>]
17                [--max-configs=<limit>] [--max-ctu-depth=<limit>]
18                [--platform=<type>] [--quiet] [--relative-paths=<paths>]
19                [--report-progress] [--rule=<rule>] [--rule-file=<file>]
20                [--std=<id>] [--suppress=<spec>] [--suppressions-list=<file>]
21                [--suppress-xml=<.xml file>] [--template='<text>'] [--verbose]
22                [--version] [--xml] [--xml-version=<version>]] [file or path]
23                ...
24

DESCRIPTION

26       Cppcheck is a command-line tool that tries to detect bugs that your
27       C/C++ compiler doesn't see. It is versatile, and can check non-standard
28       code including various compiler extensions, inline assembly code, etc.
29       Its internal preprocessor can handle includes, macros, and several
30       preprocessor commands. While Cppcheck is highly configurable, you can
31       start using it just by giving it a path to the source code.
32

OPTIONS

34       Analyze given C/C++ files for common errors.
35
36       --check-config
37           Check Cppcheck configuration. The normal code analysis is disabled
38           by this flag.
39
40       --check-library
41           Show information messages when library files have incomplete info.
42
43       -D<id>
44           By default Cppcheck checks all configurations. Use -D to limit the
45           checking. When -D is used the checking is limited to the given
46           configuration. Example: -DDEBUG=1 -D__cplusplus
47
48       -U<id>
49           By default Cppcheck checks all configurations. Use '-U' to
50           explicitly hide certain #ifdef <id> code paths from checking.
51           Example: '-UDEBUG'
52
53       --disable=<id>
54           Disable individual checks. Please refer to the documentation of
55           --enable=<id> for further details.
56
57       --enable=<id>
58           Enable additional checks. The available ids are:
59
60           all
61               Enable all checks. It is recommended to only use --enable=all
62               when the whole program is scanned, because this enables
63               unusedFunction.
64
65           warning
66               Enable warning messages
67
68           style
69               Enable all coding style checks. All messages with the
70               severities 'style', 'performance' and 'portability' are
71               enabled.
72
73           performance
74               Enable performance messages
75
76           portability
77               Enable portability messages
78
79           information
80               Enable information messages
81
82           unusedFunction
83               Check for unused functions. It is recommend to only enable this
84               when the whole program is scanned
85
86           missingInclude
87               Warn if there are missing includes
88
89           By default none of the additional checks are enabled. Several ids
90           can be given if you separate them with commas, e.g.
91           --enable=style,unusedFunction. See also --std
92
93       --error-exitcode=<n>
94           If errors are found, integer <n> is returned instead of default 0.
95           EXIT_FAILURE is returned if arguments are not valid or if no input
96           files are provided. Note that your operating system can modify this
97           value, e.g. 256 can become 0.
98
99       --errorlist
100           Print a list of all possible error messages in XML format.
101
102       --exitcode-suppressions=<file>
103           Used when certain messages should be displayed but should not cause
104           a non-zero exitcode.
105
106       --file-list=<file>
107           Specify the files to check in a text file. One filename per line.
108           When file is -, the file list will be read from standard input.
109
110       -f, --force
111           Force checking of files that have a lot of configurations. Error is
112           printed if such a file is found so there is no reason to use this
113           by default. If used together with --max-configs=, the last option
114           is the one that is effective.
115
116       -h, --help
117           Print help text.
118
119       -I <dir>
120           Give path to search for include files. Give several -I parameters
121           to give several paths. First given path is searched for contained
122           header files first. If paths are relative to source files, this is
123           not needed.
124
125       --includes-file=<file>
126           Specify directory paths to search for included header files in a
127           text file. Add one include path per line. First given path is
128           searched for contained header files first. If paths are relative to
129           source files, this is not needed.
130
131       --config-exclude=<dir>
132           Path (prefix) to be excluded from configuration checking.
133           Preprocessor configurations defined in headers (but not sources)
134           matching the prefix will not be considered for evaluation of
135           configuration alternatives.
136
137       --config-exclude-file=<file>
138           A file that contains a list of config-excludes.
139
140       --include=<file>
141           Force inclusion of a file before the checked file. Can be used for
142           example when checking the Linux kernel, where autoconf.h needs to
143           be included for every file compiled. Works the same way as the GCC
144           -include option.
145
146       -i <dir>
147           Give path to ignore. Give several -i parameters to ignore several
148           paths. Give directory name or filename with path as parameter.
149           Directory name is matched to all parts of the path.
150
151       --inconclusive
152           Allow that Cppcheck reports even though the analysis is
153           inconclusive. There are false positives with this option. Each
154           result must be carefully investigated before you know if it is good
155           or bad.
156
157       --inline-suppr
158           Enable inline suppressions. Use them by placing comments in the
159           form: // cppcheck-suppress memleak before the line to suppress.
160
161       -j <jobs>
162           Start <jobs> threads to do the checking work.
163
164       -l <load>
165           Specifies that no new threads should be started if there are other
166           threads running and the load average is at least <load> (ignored on
167           non UNIX-like systems)
168
169       --language=<language>
170           Forces cppcheck to check all files as the given language. Valid
171           values are: c, c++
172
173       --library=<cfg>
174           Use library configuration.
175
176       --max-configs=<limit>
177           Maximum number of configurations to check in a file before skipping
178           it. Default is 12. If used together with --force, the last option
179           is the one that is effective.
180
181       --max-ctu-depth=<limit>
182           Maximum depth in whole program analysis. Default is 2.
183
184       --platform=<type>
185           Specifies platform specific types and sizes.The available platforms
186           are:
187
188           unix32
189               32 bit unix variant
190
191           unix64
192               64 bit unix variant
193
194           win32A
195               32 bit Windows ASCII character encoding
196
197           win32W
198               32 bit Windows UNICODE character encoding
199
200           win64
201               64 bit Windows
202
203           By default the platform which was used to compile Cppcheck is used.
204
205       -q, --quiet
206           Only print something when there is an error.
207
208       -rp, -rp=<paths>, --relative-paths;, --relative-paths=<paths>
209           Use relative paths in output. When given, <paths> are used as base.
210           You can separate multiple paths by ';'. Otherwise path where source
211           files are searched is used. E.g. if given value is test, when
212           checking test/test.cpp, the path in output will be test.cpp instead
213           of test/test.cpp. The feature uses string comparison to create
214           relative paths, so using e.g. ~ for home folder does not work. It
215           is currently only possible to apply the base paths to files that
216           are on a lower level in the directory tree.
217
218       --report-progress
219           Report progress when checking a file.
220
221       --rule=<rule>
222           Match regular expression to create your own checks. E.g. rule "/ 0"
223           can be used to check division by zero. This command is only
224           available if cppcheck was compiled with HAVE_RULES=yes.
225
226       --rule-file=<file>
227           Use given rule XML file. See
228           https://sourceforge.net/projects/cppcheck/files/Articles/ for more
229           info about the syntax. This command is only available if cppcheck
230           was compiled with HAVE_RULES=yes.
231
232       --std=<id>
233           Set standard. The available options are:
234
235           c89
236               C code is C89 compatible
237
238           c99
239               C code is C99 compatible
240
241           c11
242               C code is C11 compatible (default)
243
244           c++03
245               C++ code is C++03 compatible
246
247           c++11
248               C++ code is C++11 compatible (default)
249
250
251       --suppress=<spec>
252           Suppress a specific warning. The format of <spec> is: [error
253           id]:[filename]:[line]. The [filename] and [line] are optional.
254           [error id] may be * to suppress all warnings (for a specified file
255           or files). [filename] may contain the wildcard characters * or ?.
256
257       --suppressions-list=<file>
258           Suppress warnings listed in the file. Each suppression is in the
259           format of <spec> above.
260
261       --suppress-xml=<.xml file>
262           Use suppressions defined in xml as described in the manual
263
264       --template='<text>'
265           Format the error messages. E.g.
266           '{file}:{line},{severity},{id},{message}' or
267           '{file}({line}):({severity}) {message}'. Pre-defined templates:
268           gcc, vs
269
270       -v, --verbose
271           More detailed error reports
272
273       --version
274           Print out version information
275
276       --xml
277           Write results in XML to error stream
278
279       --xml-version=<version>
280           Select the XML file version. Also implies --xml. Currently only
281           version 2 is available. The default version is 2.
282

AUTHOR

284       The program was written by Daniel Marjamäki and Cppcheck team. See
285       AUTHORS file for list of team members.
286

SEE ALSO

288       Full list of features: https://sourceforge.net/p/cppcheck/wiki/Home/
289

AUTHOR

291       Reijo Tomperi <aggro80@users.sourceforge.net>
292           Wrote this manpage for the Debian system.
293
295       Copyright © 2009 - 2016 Reijo Tomperi
296
297       This manual page was written for the Debian system (but may be used by
298       others).
299
300       Permission is granted to copy, distribute and/or modify this document
301       under the terms of the GNU General Public License, Version 3 or (at
302       your option) any later version published by the Free Software
303       Foundation.
304
305       On Debian systems, the complete text of the GNU General Public License
306       can be found in /usr/share/common-licenses/GPL-3.
307
308
309
310
311cppcheck                          09/20/2023                       CPPCHECK(1)
Impressum