cppcheck是一个个检测源码的工具,对编译工具的一个补充,mark

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.
-D<ID> By default Cppcheck checks all configurations. Use -D
to limit the checking to a particular configuration.
Example: '-DDEBUG=1 -D__cplusplus'.
-U<ID> By default Cppcheck checks all configurations. 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
* 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
* 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 ''. '' 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. '' can become ''.
--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.
-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++
--max-configs=<limit>
Maximum number of configurations to check in a file
before skipping it. Default is ''. 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
bit unix variant
* unix64
bit unix variant
* win32A
bit Windows ASCII character encoding
* win32W
bit Windows UNICODE character encoding
* win64
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.
--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++
C++ code is C++ compatible
* c++
C++ code is C++ 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}'
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 and
are available. The default version is .
Example usage:
# Recursively check the current folder. Print the progress on the screen and
# write errors to a file:
cppcheck . > 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.sf.net/manual.pdf
cppcheck: error: could not find or open any of the paths given.

Cppcheck - A tool for static C/C++ code analysis的更多相关文章

  1. The Ultimate List of Open Source Static Code Analysis Security Tools

    https://www.checkmarx.com/2014/11/13/the-ultimate-list-of-open-source-static-code-analysis-security- ...

  2. Top 40 Static Code Analysis Tools

    https://www.softwaretestinghelp.com/tools/top-40-static-code-analysis-tools/ In this article, I have ...

  3. 问题:Custom tool error: Failed to generate code for the service reference 'AppVot;结果:添加Service Reference, 无法为服务生成代码错误的解决办法

    添加Service Reference, 无法为服务生成代码错误的解决办法 我的解决方案是Silverlight+WCF的应用,Done Cretiria定义了需要在做完Service端的代码后首先运 ...

  4. 二十五、详述 IntelliJ IDEA 提交代码前的 Code Analysis 机制

    在我们用 IntelliJ IDEA 向 SVN 或者 Git 提交代码的时候,IntelliJ IDEA 提供了一个自动分析代码的功能,即Perform code analysis: 如上图所示,当 ...

  5. 十四、详述 IntelliJ IDEA 提交代码前的 Code Analysis 机制

    在我们用 IntelliJ IDEA 向 SVN 或者 Git 提交代码的时候,IntelliJ IDEA 提供了一个自动分析代码的功能,即Perform code analysis: 如上图所示,当 ...

  6. IntelliJ IDEA 提交代码时出现:Code analysis failed with exception: com.intellij.psi......

    IntelliJ IDEA 提交代码时出现:Code analysis failed with exception: com.intellij.psi...... 错误原因: 当我们勾选Perform ...

  7. DEA使用git提交代码时,点了commit之后卡死在performing code analysis部分,或者performing code analysis结束后没有进入下一步操作。

    把"Perform code analysis" 和 "Check TODO" 复选框前面的勾去掉就好了. 这个可能是因为所分析的目标文件太大了,造成一直分析不 ...

  8. IDEA使用git提交代码时,点了commit之后卡死在performing code analysis部分,或者performing code analysis结束后没有进入下一步操作

    把"Perform code analysis" 和 "Check TODO" 复选框前面的勾去掉就好了. 这个可能是因为所分析的目标文件太大了,造成一直分析不 ...

  9. A python tool to static sim.log duration time

    When working ALU IMS Patch team, we need to static the SU duration to add it to the patch report, th ...

随机推荐

  1. pc网页中嵌入百度地图

    pc网页中嵌入百度地图 1 打开百度地图生成器: http://api.map.baidu.com/lbsapi/creatmap/ 2 设置好了之后,点击获取代码,将代码粘贴到文件中保存为html文 ...

  2. 报名 | 蚂蚁金服ATEC科技大会 · 上海:数字金融新原力

    小蚂蚁说: 2019年1月4日,蚂蚁金服ATEC城市峰会将以“数字金融新原力(The New Force of Digital Finance)”为主题,在中国上海举办.蚂蚁金服ATEC(Ant Te ...

  3. maven 引入外部jar包的几种方式

    方式1:dependency 本地jar包 <dependency> <groupId>com.hope.cloud</groupId> <!--自定义--& ...

  4. Python 数字(Number)

    Python 数字(Number) Python 数字数据类型用于存储数值. 数据类型是不允许改变的,这就意味着如果改变数字数据类型的值,将重新分配内存空间. 以下实例在变量赋值时 Number 对象 ...

  5. 动态规划-子数组乘积小于k的总个数 Subarray Product Less Than K

    2018-09-01 23:02:46 问题求解: 问题求解: 最开始的时候,一眼看过去就是一条 dp 嘛,保存每个数字结尾的长度和,最后求和就好,至于长度如何求,本题中需要用滑动窗口来维护. 很好的 ...

  6. ubuntu 安装 firefox 的 jre plugin

    https://www.java.com/en/download/help/enable_browser_ubuntu.xml Mozilla Firefox Become the root user ...

  7. learn python the hard way 习题1~5总结

    习题1 print 语句print('Yay! Printing.')print('I "said" do not touch this') 习题2:注释和 # 号 #(octot ...

  8. python cook 整理

    1.字符串分割 单个分隔符    'abc'.split('b')  >> ['a','c'] 多个分隔符    re.split(r'[b,d]','abcde') >>&g ...

  9. 本地广播的简单示例 --Android开发

    1.局部通知管理器LocalBroadcastManager,用于同一个应用中不同组件之间发送广播.由于是在同应用中发送广播,所以使用它安全性.效率也会提高. 2.本例实现简单的发送本地广播的案例 点 ...

  10. LeetCode--292--Nim游戏

    问题描述: 你和你的朋友,两个人一起玩 Nim游戏:桌子上有一堆石头,每次你们轮流拿掉 1 - 3 块石头. 拿掉最后一块石头的人就是获胜者.你作为先手. 你们是聪明人,每一步都是最优解. 编写一个函 ...