pc lint 9.0e集成到vc2005

    技术2022-05-20  37

          PCLint/FlexeLint 是一款代码静态分析工具,它的作用就是查找C/C++程序的错误与缺陷(bugs),分析代码存在的潜在问题,比编译器更要严格。具体介绍可参考http://wenku.baidu.com/view/b8786531b90d6c85ec3ac66c.html,本文主要讲解pc lint 9.0e如何集成到vc2005上。

          可以到http://download.csdn.net/source/2718041下载pc lint 9.0e版,下载完后点击PC-lint.9.0e/pclint9setup.exe进行安装,这里以安装到C:/lint介绍。安装完成后勾选I want to run the configuration program now.点击finish进入配置页面,配置选项依次为:

    1、C:/lint(这个是pc lint的安装目录),Create a new STD.LNT

    2、Microsoft Visual C++ 2005 (co-msc80.lnt)

    3、32-bit Flat Model(-ms, -si4, -sp4)

    4、Active Template Library(ATL),Microsoft Foundation Class Library,Standard Template Library,Windows 32-bit

    5、Scott Meyers(Effective C++ More Effective C++ and Effective C++ 3rd Edition),Dan Saks,MISRA 2004

    6、Create -i options

    7、这里将vc的包含目录加进去,我加的是以下三个

    D:/Microsoft Visual Studio 8/VC/includeD:/Microsoft Visual Studio 8/VC/atlmfc/includeD:/Microsoft Visual Studio 8/VC/PlatformSDK/Include

    8、No

    9、(env-vc8.lnt) Microsoft's Visual C++.NET 2005

    10、Prepend my PC-lint directory to my PATH(create LSET.BAT)

    完成

          配置好pc lint之后,下面就将它集成到vc2005中,打开vc2005--Tools--External Tools,点击Add按钮Title为pc_lint(这个可以任意命名),Command为 C:/lint/lint-nt.exe(这个为lint-nt的绝对路径),Arguments为-i"c:/lint" std.lnt env-vc8.lnt "$(ItemDir)$(ItemFileName)$(ItemExt)",Initial directory为$(ItemDir),勾选"Use Output windows",点击OK

          好了,现在写一段程序测试一下吧。main.cpp文件内容如下:

    #include <stdio.h>

    int main(){ int a; printf("a = %d/n", a); return 0;}

    在VC2005中打开该文件,点击Tools--pc_lint,结果如下:

    --- Module:   C:/Documents and Settings/zwu/Desktop/new.cpp (C++)    printf("a = %d/n", a);C:/Documents and Settings/zwu/Desktop/new.cpp(6): error 530: (Warning -- Symbol 'a' (line 5) not initialized --- Eff. C++ 3rd Ed. item 4)C:/Documents and Settings/zwu/Desktop/new.cpp(5): error 830: (Info -- Location cited in prior message)}C:/Documents and Settings/zwu/Desktop/new.cpp(8): error 953: (Note -- Variable 'a' (line 5) could be declared as const --- Eff. C++ 3rd Ed. item 3)C:/Documents and Settings/zwu/Desktop/new.cpp(5): error 830: (Info -- Location cited in prior message)

    --- Global Wrap-up

     error 900: (Note -- Successful completion, 4 messages produced)


    最新回复(0)