|
最近项目正在使用PC-Lint做代码的静态检查,从一开始对它的不了解抵触它,到现在我希望用一系列的文章来介绍它,的确个人认为它是一个不错的静态代码检测工具。它不但能够监测出许多语法逻辑上的隐患,而且也能够有效地帮你提出许多程序在空间利用、运行效率上的改进点。不仅对于个人或者公司,PC-Lint做代码静态检查都是具有明显的好处:
1. 对于公司可以控制代码的质量,使代码符合公司的代码规范,从而尽可能减少bug的产生。
2. 可以通过PC-Lint的检查代码,从而发现代码运行效率上的改进点,改进代码运行效率。
3. 对于个人也是一个学习的过程,个人可以从PC-Lint报出的error里学习到自己写的代码到底还有哪些不足的地方,并且可以思考这些不足的地方为什么PC-Lint认为是一个可以改进点,从而使自己的程序日臻完美,完全用实践来证明理论,而不是天天拿着Effective C++/More Effective C++诵读。
这么多的优点,没有理由不让你了解PC-Lint,所以我准备下一步用另外两篇文章来介绍PC-Lint:
1. PC-Lint的安装、设置以及公司内部PC-Lint Criteria的设立,这部分需要结合Clear-Case来说明对于一个企业是如何全局控制PC-Lint的安装与rule版本的。
2. PC-Lint的使用,在这里会根据个人在项目中的经验对一些常见的rule进行解释,并根据自己的切身体会介绍如何用好PC-Lint.
Wrapper |
Private command wrapper sets |
Rules |
Private rule sets |
Gimpel |
Original Gimpel Software |
In
“Wrapper” directory, there are two main files called
“PCLint_VC_Project.cmd” and “Proj2lnt.pl”, I want to use a diagram to
explain the relationship and functions between them.
The “PCLint_VC_Project.cmd”
file is an entry for lint the source file/project in VS. We can add a
plug in VS SDE. You can referenced the related article at: http://blog.vckbase.com/eyesonyhm/archive/2010/05/14/42330.html
Syntax:
PCLint_VC_Project.cmd Project Configuration RuleSet [File]
Example:
PCLint_VC_Project.cmd example.vcproj Debug [abc.cpp]
Without specifying a [File] the whole project is linted.
The lint wrapper works in three steps.
The
file “Proj2lnt.pl” is used to translate the vcproj file in to lint
format. Because in every lint process, it needs the configuration from
project file, like include path, macro definition etc.
The related file is in:
http://blog.vckbase.com/Files/eyesonyhm/proj2lnt.zip