博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cppcheck代码检测
阅读量:7120 次
发布时间:2019-06-28

本文共 6803 字,大约阅读时间需要 22 分钟。

cppcheck -h

Cppcheck - A tool for static C/C++ code analysis

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.

Options:

--append=<file> This allows you to provide information about functions
by providing an implementation for them.
--check-config Check cppcheck configuration. The normal code
analysis is disabled by this flag.
--check-library Show information messages when library files have
incomplete info.
-D<ID> Define preprocessor symbol. Unless --max-configs or
--force is used, Cppcheck will only check the given
configuration when -D is used.
Example: '-DDEBUG=1 -D__cplusplus'.
-U<ID> Undefine preprocessor symbol. Use -U to explicitly
hide certain #ifdef <ID> code paths from checking.
Example: '-UDEBUG'
--enable=<id> Enable additional checks. The available ids are:
* all
Enable all checks. It is recommended to only
use --enable=all when the whole program is
scanned, because this enables unusedFunction.
* warning
Enable warning messages
* style
Enable all coding style checks. All messages
with the severities 'style', 'performance' and
'portability' are enabled.
* performance
Enable performance messages
* portability
Enable portability messages
* information
Enable information messages
* unusedFunction
Check for unused functions. It is recommend
to only enable this when the whole program is
scanned.
* missingInclude
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
--error-exitcode=<n> If errors are found, integer [n] is returned instead of
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'.
--errorlist Print a list of all the error messages in XML format.
--exitcode-suppressions=<file>
Used when certain messages should be displayed but
should not cause a non-zero exitcode.
--file-list=<file> Specify the files to check in a text file. Add one
filename per line. When file is '-,' the file list will
be read from standard input.
-f, --force Force checking of all configurations in files. If used
together with '--max-configs=', the last option is the
one that is effective.
-h, --help Print this help.
-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.
--includes-file=<file>
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.
--include=<file>
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.
-i <dir or file> Give a source file or source file directory to exclude
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 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.
--inline-suppr Enable inline suppressions. Use them by placing one or
more comments, like: '// cppcheck-suppress warningId'
on the lines before the warning to suppress.
-j <jobs> Start [jobs] threads to do the checking simultaneously.
--language=<language>, -x <language>
Forces cppcheck to check all files as the given
language. Valid values are: c, c++
--library=<cfg>
Use library configuration.
--max-configs=<limit>
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.
--platform=<type> Specifies platform specific types and sizes. The
available 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
-q, --quiet Only print error messages.
-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.
--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:
https://sourceforge.net/projects/cppcheck/files/Articles/
--std=<id> Set standard.
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'
--suppress=<spec> Suppress warnings that match <spec>. The format of
<spec> is:
[error id]:[filename]:[line]
The [filename] and [line] are optional. If [error id]
is a wildcard '*', all error ids match.
--suppressions-list=<file>
Suppress warnings listed in the file. Each suppression
is in the same format as <spec> above.
--template='<text>' Format the error messages. E.g.
'{file}:{line},{severity},{id},{message}' or
'{file}({line}):({severity}) {message}' or
'{callstack} {message}'
Pre-defined templates: gcc, vs, edit.
-v, --verbose Output more detailed error information.
--version Print out version number.
--xml Write results in xml format to error stream (stderr).
--xml-version=<version>
Select the XML file version. Currently versions 1 and
2 are available. The default version is 1.
Example usage:
# 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.sourceforge.net/manual.pdf

转载于:https://www.cnblogs.com/sky-heaven/p/11018155.html

你可能感兴趣的文章
python 基础 学习 内置函数
查看>>
VMware (CentOS 6.x)克隆导致的网卡问题
查看>>
帧中继环境下ospf的使用(点到点模式)
查看>>
编程语言和shell编程的基础内容以及grep、egrep命令及相应的正则表达式和用法...
查看>>
819C - RAW文件系统、集成文件系统
查看>>
我的友情链接
查看>>
Locating Elements(一)
查看>>
傻瓜式-构建SOHO小型局域网web FTP服务器
查看>>
verilog奇偶分频
查看>>
Vim用原生雅黑Consolas混合字体
查看>>
vSphere 5.5 VM整合磁盘失败之—文件被锁定无法访问
查看>>
SEO
查看>>
将文本文件内容存储在DataSet中的方法总结
查看>>
如何对Mac中的磁盘进行检查修复
查看>>
腾讯接入支付宝 京东、苏宁易购在等是什么
查看>>
win7下的python2.7和pip的环境安装
查看>>
Drupal常用开发工具(二)——Drupal for Firebug
查看>>
Win2K8R2IIS7命令添加服务器角色
查看>>
贪心算法
查看>>
ANR问题的log位置
查看>>