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

DESCRIPTION

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

OPTIONS

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

AUTHOR

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

SEE ALSO

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

AUTHOR

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