天天看點

代碼檢查工具 cppcheck 的使用

從 ​​http://cppcheck.sourceforge.net/​​   下載下傳最新的cppcheck。

代碼檢查工具 cppcheck 的使用

根據自己環境下載下傳相應的版本:

下載下傳後,安裝即可:

安裝後,

代碼檢查工具 cppcheck 的使用

其中cppcheckgui.exe是可視化程式,用于檢測代碼。還有一種就是指令方式,和內建到qt中使用

指令方式:

代碼檢查工具 cppcheck 的使用

1、VS

參考這裡(​​http://avitebskiy.blogspot.tw/2012/10/poor-mans-visual-studio-cppcheck.html​​),可以友善的把cppcheck嵌入到vs,然後可以友善的對一個檔案進行檢查,而且支援錯誤跳轉。

  • click theAddbutton
  • set theTitle, for exampleCppcheck
  • setCommandtoC:\Program Files (x86)\Cppcheck\cppcheck.exe
  • setArgumentsto --quiet --verbose --template=vs $(ItemPath)
  • setInitial Directoryto$(ItemDir)
  • make sure Use Output windowcheckbox is enabled
  • click on theMove Upbutton 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
  • clickOK.

qt方式:參數中:--enable=all %{CurrentProject:Path},工作目錄:%{CurrentProject:Path}

代碼檢查工具 cppcheck 的使用

使用方法: