前言
一、下載
二、揭開PC-Lint9的神祕面紗
D:\PC-Lint9>lint-nt -v PC-lint for C/C++ (NT) Vers. 9.00a, Copyright Gimpel Software 1985-2008
三、升級到最新版本
D:\PC-Lint9>update.bat D:\PC-Lint9>PATCH.EXE LP9-A-B.RTP D:\PC-Lint9>PATCH.EXE LP9-B-C.RTP D:\PC-Lint9>PATCH.EXE LP9-C-D.RTP D:\PC-Lint9>PATCH.EXE LP9-D-E.RTP D:\PC-Lint9>PATCH.EXE LP9-E-F.RTP D:\PC-Lint9> D:\PC-Lint9> D:\PC-Lint9>lint-nt -v PC-lint for C/C++ (NT) Vers. 9.00f, Copyright Gimpel Software 1985-2010
四、在線試用
五、若干例子
-i"D:\PC-Lint9.0\lnt" co-msc90.lnt -i"C:\Program Files\Microsoft Visual Studio 9.0\VC\include"
#include <string.h> class X { int *p; public: X() { p = new int[20]; } void init() { memset( p, 20, 'a' ); } ~X() { delete p; } };
D:\Projects\Lab\PC-lint9-test\tests>lint-nt std.lnt simple.cpp PC-lint for C/C++ (NT) Vers. 9.00f, Copyright Gimpel Software 1985-2010 --- Module: simple.cpp (C++) _ { p = new int[20]; } simple.cpp(8) : Info 1732: new in constructor for class 'X' which has no assignment operator simple.cpp(8) : Info 1733: new in constructor for class 'X' which has no copy constructor _ { memset( p, 20, 'a' ); } simple.cpp(10) : Warning 669: Possible data overrun for function 'memset(void *, int, unsigned int)', argument 3 (size=97) exceeds argument 1 (size=80) [Reference: file simple.cpp: lines 8, 10] simple.cpp(8) : Info 831: Reference cited in prior message simple.cpp(10) : Info 831: Reference cited in prior message _ { delete p; } simple.cpp(12) : Warning 424: Inappropriate deallocation (delete) for 'new[]' data --- Wrap-up for Module: simple.cpp Info 753: local class 'X' (line 3, file simple.cpp) not referenced simple.cpp(3) : Info 830: Location cited in prior message --- Global Wrap-up Info 1714: Member function 'X::init(void)' (line 9, file simple.cpp) not referenced simple.cpp(9) : Info 830: Location cited in prior message
D:\Projects\Lab\PC-lint9-test\tests\multimodule>lint-nt std.lnt files.lnt PC-lint for C/C++ (NT) Vers. 9.00f, Copyright Gimpel Software 1985-2010 --- Module: a.cpp (C++) --- Module: b.cpp (C++) _ int b = a; b.cpp(3) : Warning 1544: Value of variable 'a' (line 4, file a.cpp) indeterminate (order of initialization) a.cpp(4) : Info 830: Location cited in prior message --- Global Wrap-up
D:\Projects\Lab\PC-lint9-test\tests>lint-nt multi-threading.cpp PC-lint for C/C++ (NT) Vers. 8.00w, Copyright Gimpel Software 1985-2007 --- Module: multi-threading.cpp (C++) _ //lint -sem( reader, thread ) multi-threading.cpp 6 Warning 425: 'unrecognized name' in processing semantic 'thread' at token 'thread' _ //lint -sem( Lock::Lock, thread_lock ) multi-threading.cpp 7 Warning 425: 'unrecognized name' in processing semantic 'thread_lock' at token 'thread_lock' _ //lint -sem( Lock::~Lock, thread_unlock ) multi-threading.cpp 8 Warning 425: 'unrecognized name' in processing semantic 'thread_unlock' at token 'thread_unlock' D:\Projects\Lab\PC-lint9-test\tests> D:\Projects\Lab\PC-lint9-test\tests> D:\Projects\Lab\PC-lint9-test\tests>set path=D:\Tools\CMD\Lint\SmartLint\PC-Lint9.0 D:\Projects\Lab\PC-lint9-test\tests>lint-nt multi-threading.cpp PC-lint for C/C++ (NT) Vers. 9.00f, Copyright Gimpel Software 1985-2010 --- Module: multi-threading.cpp (C++) --- Thread messages: Warning 457: Function 'h(void)' of thread 'main(void)' has an unprotected write access to variable 'x' which is used by function 'h(void)' of thread 'reader(void)' Warning 458: Function 'h(void)' of thread 'main(void)' has an unprotected read access to variable 'y' which is modified by function 'g(void)' of thread 'reader(void)'
六、輔助工具
七、PC-Lint9.0新增功能
6、“宏淨化(Macro Scavenging)”。這個功能想必是爲了解決PC-Lint與GCC不同版本配合中需要大量人工配置的尷尬局面吧。聽起來不錯的一個解決方案,具有較強的通用性。
7、新加入的“-sem”語法:成員方法的初始化/回收職能標識、inout類參數標識、多線程分析輔助標識…… 這一系列補充標識都是非常有實用價值的,尤其是前兩項,解決了C++工程維護中擴充成員時經常碰到的忘記寫配套的初始化或釋放處理的頑疾。