汉字均为翻译 以下翻译均采用谷歌翻译
Syntax: 语法
cppcheck [OPTIONS] [files or paths]If a directory is given instead of a filename, *.cpp, *.cxx, *.cc, *.c++, *.c,
*.tpp, and *.txx files are checked recursively from the given directory.
如果给出目录而不是文件名* .cpp,*。cxx,* .cc,* .c ++,* .c,
* .tpp和* .txx文件从给定目录递归检查。
Options:
--cppcheck-build-dir=<dir>
Analysis output directory. Useful for various data.
Some possible usages are; whole program analysis,
incremental analysis, distributed analysis.
分析输出目录。 有用的各种数据。
一些可能的用法是: 整个程序分析,
增量分析,分布式分析。
analysis is disabled by this flag.
检查cppcheck配置。 正常代码
分析由此标志禁用
incomplete info.
库文件具有时显示信息消息
不完整的信息。
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.
要从配置中排除的路径(前缀)
检查。 在中定义的预处理器配置
匹配前缀的头(但不是源)不会
被考虑进行评价。
A file that contains a list of config-excludes
包含配置排除的列表的文件
--dump Dump xml data for each translation unit. The dumpfiles have the extension .dump and contain ast,
tokenlist, symboldatabase, valueflow.
转储每个翻译单元的xml数据。 转储
文件具有扩展名.dump并包含ast,
tokenlist,symboldatabase,valueflow。
--force is used, Cppcheck will only check the given
configuration when -D is used.
Example: '-DDEBUG=1 -D__cplusplus'.
定义预处理器符号。 除非--max-configs或
--force被使用,Cppcheck只会检查给定
配置时使用-D。
示例:'-DDEBUG = 1 -D__cplusplus'。
hide certain #ifdef <ID> code paths from checking.
Example: '-UDEBUG'
未定义预处理器符号。 使用-U显式
从检查中隐藏某些#ifdef <ID>代码路径。
示例:'-UDEBUG'
further processing.
在stdout上打印预处理器输出,不做任何操作
进一步处理。
--enable=<id> Enable additional checks. The available ids are:
启用其他检查。 可用的ID是:
* allEnable all checks. It is recommended to only
use --enable=all when the whole program is
scanned, because this enables unusedFunction.
启用所有检查。 建议只有
使用--enable = all当整个程序是
扫描,因为这启用unusedFunction。
Enable warning messages
启用警告消息
* styleEnable all coding style checks. All messages
with the severities 'style', 'performance' and
'portability' are enabled.
启用所有编码风格检查。 所有消息
具有严重的风格,性能和
'可移植性'。
Enable performance messages
启用性能消息
* portability 可移植性Enable portability messages
启用可移植性消息
* informationEnable information messages
启用信息消息
* unusedFunctionCheck for unused functions. It is recommend
to only enable this when the whole program is
scanned.
检查未使用的功能。 这是推荐
只有当整个程序是启用这个
扫描。
Warn if there are missing includes. For
detailed information, use '--check-config'.
Several ids can be given if you separate them with
commas. See also --std
如果有缺失包括警告。 对于
详细信息,请使用“--check-config”。
如果您将它们分开,可以给出几个ids
逗号。 另请参见--std
the default '0'. '1' 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'.
如果发现错误,则返回integer [n],而不是返回
默认为'0'。 返回'1'
如果参数无效或没有输入文件
提供。 注意,您的操作系统可以修改
这个值,例如。 '256'可以变为'0'。
--errorlist Print a list of all the error messages in XML format.
以XML格式打印所有错误消息的列表。
--doc Print a list of all available checks.
打印所有可用检查的列表。
--exitcode-suppressions=<file>Used when certain messages should be displayed but
should not cause a non-zero exitcode.
在应显示某些消息时使用
不应该导致非零退出代码。
filename per line. When file is '-,' the file list will
be read from standard input.
指定要在文本文件中检查的文件。 添加一个
filename每行。 当文件是 - 时,文件列表将
从标准输入读取。
together with '--max-configs=', the last option is the
one that is effective.
强制检查文件中的所有配置。 如果使用
加上'--max-configs =',最后一个选项是
一个是有效的。
-I <dir> 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.
指定搜索包含文件的路径。 给几个-I
参数给出几个路径。 首先给定的路径是
首先搜索包含的头文件。 如果路径
相对于源文件,这不是必需的。
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.
指定搜索包含的标题的目录路径
文件在文本文件中。 每行添加一个包含路径。
首先给定的路径搜索包含的头
文件。 如果路径相对于源文件,
这不是必需的。
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.
强制在选中文件之前包含文件。 能够
例如在检查Linux内核时,
其中每个文件都需要包含autoconf.h
编译。 工作方式与GCC相同 - 包括
选项。
from the check. This applies only to source files so
header files included by source files are not matched.
Directory name is matched to all parts of the path.
给出要排除的源文件或源文件目录
从检查。 这仅适用于源文件等
源文件包括的头文件不匹配。
目录名称与路径的所有部分匹配。
inconclusive.
There are false positives with this option. Each result
must be carefully investigated before you know if it is
good or bad.
即使分析是,仍允许Cppcheck报告
不确定。
这个选项有假阳性。 每个结果
必须仔细调查,才知道是否
是好是坏。
more comments, like: '// cppcheck-suppress warningId'
on the lines before the warning to suppress.
启用内联抑制。 通过放置一个或使用它们
更多评论,如:'// cppcheck-suppress warningId'
在线前警告压制。
-j <jobs> Start <jobs> threads to do the checking simultaneously.
启动<jobs>线程以同时进行检查。
--language=<language>, -x <language>Forces cppcheck to check all files as the given
language. Valid values are: c, c++
强制cppcheck检查所有文件作为给定
语言。 有效值为:c,c ++
and functions. With such information Cppcheck
understands your your code better and therefore you
get better results. The std.cfg file that is
distributed with Cppcheck is loaded automatically.
For more information about library files, read the
manual.
加载包含类型信息的文件<cfg>
和功能。 有这样的信息Cppcheck
理解你的代码更好,因此你
获得更好的效果。 std.cfg文件是
分发与Cppcheck自动加载。
有关库文件的详细信息,请阅读
手册。
Studio Solution (*.sln), Visual Studio Project
(*.vcxproj), or compile database
(compile_commands.json). The files to analyse,
include paths, defines, platform and undefines in
the specified file will be used.
在项目上运行Cppcheck。 <file>可以是Visual
Studio解决方案(* .sln),Visual Studio项目
(* .vcxproj),或编译数据库
(compile_commands.json)。 要分析的文件,
包括路径,定义,平台和未定义
将使用指定的文件。
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.
要在文件中检查的最大配置数
跳过它之前。 默认值为“12”。 如果一起使用
与“--force”,最后一个选项是一个
有效。
Specifies platform specific types and sizes. The
available builtin platforms are:
* unix32
32 bit unix variant
* unix64
64 bit unix variant
* win32A
32 bit Windows ASCII character encoding
* win32W
32 bit Windows UNICODE character encoding
* win64
64 bit Windows
* native
Unspecified platform. Type sizes of host system
are assumed, but no further assumptions.
指定平台特定类型和大小。 的
可用的内置平台有:
* unix32
32位unix变体
* unix64
64位unix变体
* win32A
32位Windows ASCII字符编码
* win32W
32位Windows UNICODE字符编码
* win64
64位Windows
*本机
未指定的平台。 键入主机系统的大小
假设,但没有进一步的假设。
-q, --quiet Do not show progress reports.
不显示进度报告。
-rp, --relative-paths-rp=<paths>, --relative-paths=<paths>
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.
We use 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.
在输出中使用相对路径。 当给定时,<路径>是
用作基础。 您可以通过';'分隔多个路径。
否则使用搜索源文件的路径。
我们使用字符串比较创建相对路径,所以
使用。 〜为home文件夹不工作。 它是
目前只能应用基本路径
目录树中较低级别的文件。
--report-progress Report progress messages while checking a file.
检查文件时报告进度消息。
--rule=<rule> Match regular expression.
匹配正则表达式。
--rule-file=<file> Use given rule file. For more information, see:http://sourceforge.net/projects/cppcheck/files/Articles/
使用给定的规则文件。 有关详细信息,请参阅:
http://sourceforge.net/projects/cppcheck/files/Articles/
The available options are:
* posix
POSIX compatible code
* c89
C code is C89 compatible
* c99
C code is C99 compatible
* c11
C code is C11 compatible (default)
* c++03
C++ code is C++03 compatible
* c++11
C++ code is C++11 compatible (default)
More than one --std can be used:
'cppcheck --std=c99 --std=posix file.c'
设置标准。
可用的选项有:
* posix
POSIX兼容代码
* c89
C代码与C89兼容
* c99
C代码与C99兼容
* c11
C代码是C11兼容(默认)
* c ++ 03
C ++代码与C ++ 03兼容
* c ++ 11
C ++代码是C ++ 11兼容(默认)
可以使用多个--std:
'cppcheck --std = c99 --std = posix file.c'
<spec> is:
[error id]:[filename]:[line]
The [filename] and [line] are optional. If [error id]
is a wildcard '*', all error ids match.
禁止符合<spec>的警告。 格式为
<spec>是:
[error id]:[filename]:[line]
[filename]和[line]是可选的。 如果[错误id]
是通配符“*”,所有错误ID都匹配。
Suppress warnings listed in the file. Each suppression
is in the same format as <spec> above.
抑制文件中列出的警告。 每次抑制
与上述<spec>格式相同。
'{file}:{line},{severity},{id},{message}' or
'{file}({line}):({severity}) {message}' or
'{callstack} {message}'
Pre-defined templates: gcc, vs, edit.
格式化错误消息。 例如。
'{file}:{line},{severity},{id},{message}'或
'{file}({line}):({severity}){message}'或
'{callstack} {message}'
预定义模板:gcc,vs,编辑。
-v, --verbose Output more detailed error information.
输出更详细的错误信息。
--version Print out version number.--xml Write results in xml format to error stream (stderr).
将结果以xml格式写入错误流(stderr)。
--xml-version=<version>Select the XML file version. Currently versions 1 and
2 are available. The default version is 1.
选择XML文件版本。 目前版本1和
2可用。 默认版本为1。
# Recursively check the current folder. Print the progress on the screen and
# write errors to a file:
cppcheck . 2> err.txt
# Recursively check ../myproject/ and don't print progress:
cppcheck --quiet ../myproject/
# Check test.cpp, enable all checks:
cppcheck --enable=all --inconclusive --std=posix test.cpp
# Check f.cpp and search include files from inc1/ and inc2/:
cppcheck -I inc1/ -I inc2/ f.cpp
For more information:
http://cppcheck.net/manual.pdf