代码检查工具 cppcheck 的使用

来源:互联网 发布:god域名 编辑:程序博客网 时间:2024/06/09 21:38

从 http://cppcheck.sourceforge.net/   下载最新的cppcheck。


根据自己环境下载相应的版本:

下载后,安装即可:

安装后,

其中cppcheckgui.exe是可视化程序,用于检测代码。还有一种就是命令方式,和集成到qt中使用

命令方式:


1、VS

参考这里(http://avitebskiy.blogspot.tw/2012/10/poor-mans-visual-studio-cppcheck.html),可以方便的把cppcheck嵌入到vs,然后可以方便的对一个文件进行检查,而且支持错误跳转。

  • click the Add button
  • set the Title, for example Cppcheck
  • set Command to C:\Program Files (x86)\Cppcheck\cppcheck.exe
  • set Arguments to --quiet --verbose --template=vs $(ItemPath)
  • set Initial Directory to $(ItemDir)
  • make sure Use Output window checkbox is enabled
  • click on the Move Up button repeatedly until your entry is at the top of the list, this will make it easier to identify you new command as you can count on it being calledTools.ExternalCommand1
  • click OK.
qt方式:参数中:--enable=all %{CurrentProject:Path},工作目录:%{CurrentProject:Path}


使用方法:


检测结果:





阅读全文
0 0
原创粉丝点击