Poor Man’s Visual Studio Cppcheck Integration
来源:互联网 发布:c语言case语句用法 编辑:程序博客网 时间:2024/04/20 17:15
Introduction
Cppcheck is a good tool to have in your arsenal. Anything that helps me avoid stupid mistakes is very welcome. The problem is that if you use Visual Studio, you either have to use the separate Cppcheck GUI or pay an arm and a leg for something like Visual Lint. If you want a more convenient way to run Cppcheck on your code, but don't want to shell out $200 for the privilege, there's a fairly easy way to do a simple integration.
This article is a re-post from http://avitebskiy.blogspot.com/2012/10/poor-mans-visual-studio-cppcheck.html.
Getting Started
First things first, download the latest version Cppcheck from http://cppcheck.sourceforge.net/ and install it. This will give you both the command line version and the GUI version of Cppcheck.
Create a Visual Studio External Tool
In Visual Studio, open menu Tools→External Tools...
- 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 called Tools.ExternalCommand1
- Click OK.
Voila! You now have a Cppcheck entry in your Tools menu:
Use the Tool
You can now use select the Cppcheck menu entry any time you want to run Cppcheck on a file. The cool thing about the --template=vs switch is that you can click on a Cppcheck error and Visual Studio will automatically take you to that line of code:
Automate Cppcheck to Run on File Save
Now that we have created a command to run Cppcheck, we can have it run automatically after a file save:
- Go to menu Tools→Macros→Macros IDE, this will bring up a the Macros IDE
- On the left hand side there should be a Project Explorer panel
- In the Project Explorer panel, double click on EnvironmentEvents module
- Insert the following code in the module:
Private Sub DocumentEvents_DocumentSaved(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentSaved If Document.Language = "C/C++" Then DTE.ExecuteCommand("Tools.ExternalCommand1") Document.Activate() End IfEnd Sub
- Now save the module, close the Macros IDE, and you're good to go
http://www.codeproject.com/Tips/472065/Poor-Man-s-Visual-Studio-Cppcheck-Integration
按照如上链接设置后,发现神马都输出不了。经过研究把Arguments改为如下格式即可:
cppcheck --quiet --verbose --enable=all --template=vs --std=c++11 $(ItemPath)
原因应该是缺少了 -enable=all 应该是cppcheck新版本新加的功能。
- Poor Man’s Visual Studio Cppcheck Integration
- KitKat - The Lazy/Poor Man's Rootkit
- KitKat - The Lazy/Poor Man's Rootkit
- Poor Man’s Training Data: Graph-Based Semi-Supervised Learning
- Visual Studio Integration 架构----VSPackage
- 【2012年腾讯俱乐部ACM赛新手组1004】XOR的用法-Poor man on the Single’s Day
- A Guide To MSDN Integration (Visual Studio 6.0)
- Unity说明文档翻译-Visual Studio C# Integration
- Bill Gates Centimillionaire and one poor man.
- WOJ1045-Flymouse's Poor English
- CPPCheck
- Cppcheck
- Visual Studio 2005 编译 Programmer's Notepad
- What's New in Visual Studio 2010
- not to be a poor man,hadoop i'am comming
- Beginners Guide to SQL Server Integration Services Using Visual Studio 2005
- Beginners Guide to SQL Server Integration Services Using Visual Studio 2005
- poor
- mina教程
- Storm 实时性分析
- 程序员面试题精选100题(01)-把二元查找树转变成排序的双向链表[数据结构
- 在lua中实现printf
- MYSQL SHOW FULL PROCESSLIST\G
- Poor Man’s Visual Studio Cppcheck Integration
- python 专题十一 基本知识
- Linux命令tree - 以树状图列出目录的内容
- 封80端口应对策略 Nginx反向代理For WIN2003超级傻瓜式配置
- Android蓝牙开发浅谈
- 110901 Bicoloring
- Android MID 3G 移植
- java 模拟表单方式提交上传文件
- Android优化