代码检查工具 cppcheck 的使用

从 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}

使用方法:

检测结果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

vqt5_qt6

你的鼓励是我们创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值