【正文】
andard keywords, which have bee known as the Microsoft Keywords. These are listed in Section Compiler Codes under the option cmsc. The Microsoft keywords have bee so prevalent in C/C++ pilers supporting operating systems following Microsoft standards that it is somewhat safer to include them than to exclude them. 排除或包含其中一部分關(guān)鍵字:例:+rw(__inline) // activate the __inline keyword預處理器語句例:+ppw(import) // activate import內(nèi)嵌匯編代碼cmsc+rw(_asm,__asm)+ppw(sam)+ppw_asgn+ppw(asm,endasm)Another sequence is:asmassemblycodeendasmFor this +ppw(asm,endasm) is needed.+pragma(asm, off)+pragma(endasm, on)Yet another convention is:pragma asmassemblycodepragma endasmFor this you need to define the two pragmas with+pragma(asm, off)+pragma(endasm, on)庫(LIBRARIES):wlib(1) // sets the warning level within library headers to 1 // (no warnings, just syntax errors). Comment out if you // are actually linting library headers. This // option makes obsolete options of the form elib(axxx) where // xxx = 400 which may be retained for historical reasons.如何讓PCLint將頭文件作為庫文件處理?例如://lint w3//lint elib(755)//lint vfinclude include void main(){ printf( hello world\n )。void main(){ Count n。 }PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ n = stop 。amp。 in context: return) Global Wrapup error 900: (Note Successful pletion, 1 messages produced)Tool returned code: 1改為://lint strong(Ab,Bool)include typedef int Bool。 in Boolean context) Global Wrapup error 900: (Note Successful pletion, 1 messages produced)Tool returned code: 1例2://lint strong( AJXb, Bool )//lint strong( AJX, BitField )include typedef int Bool。 // strong type violation = 2。 // strong type violationD:\PCLint\MyTest\Test1\(17): error 632: (Warning Assignment to strong type 39。f:禁止1被當成是布爾類型index指定索引類型index( flags, ixtype, sitype [, sitype] ... )flags: c allow Constants as well as ixtype, to be used as indices.(允許常量像ixtype一樣作為索引)d allow array Dimensions to be specified without using an ixtype.(允許數(shù)組維數(shù)定義時不用ixtype)例1://lint strong( AzJX, Count, Temperature )//lint index( d, Count, Temperature )// Only Count can index a Temperatureinclude typedef float Temperature。 i++ ) t[i] = 。)D:\PCLint\MyTest\Test1\(14): error 637: (Warning Expected index type 39。 in relational) t[i] = 。)D:\PCLint\MyTest\Test1\(17): error 632: (Warning Assignment to strong type 39。 for( i = 0。Count39。typedef int Count。 i++ ) t[i] = (Temperature)。typedef int Row_Ix。 scr[ row ][ col ] = BLANK。) scr[col][row] = BLANK。Att_Char39。 f2) // Warn because of J flag f2 = f2 | F_ONE。 in context: assignment) if(f1 amp。 in context: assignment)D:\PCLint\MyTest\Test1\(18): error 633: (Warning Assignment from a strong type 39。則會形成如下類型層次:If an object of type Small is assigned to a variable of type Flags1 or Flags, no strong type violatio。 // Warn Flag2 = Flag1D:\PCLint\MyTest\Test1\(18): error 632: (Warning Assignment to strong type 39。 in context: assignment)D:\PCLint\MyTest\Test1\(14): error 633: (Warning Assignment from a strong type 39。 f2 = f1。Col_Ix39。 for strong type 39。Col_Ix col。typedef Att_Char Row[80]。 for( i = 0。Temperature39。 i 100。 // pointers are also checkedvoid main(){ Count i。 for strong type 39。 i++ )D:\PCLint\MyTest\Test1\(15): error 638: (Warning Strong type mismatch for type 39。 for strong type 39。 // Warnings, no c flag for( i = 0。f39。Bool39。 // OK = (Bool) 0。 // Warning}則提示:PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ if(a)D:\PCLint\MyTest\Test1\(7): error 640: (Warning Expected strong type 39。 // WarningD:\PCLint\MyTest\Test1\(8): error 632: (Warning Assignment to strong type 39。n39。 Bool stop。}LINT對象模塊Please Note. Lint Object Modules are used solely to improve the speed of processing previously linted modules and the speed improvements are only noticeable with very large files. They do not offer any additional error checking. In fact some error checking is lost as the Lint Object Modules do not retain all the information present in the original source code.強類型例:include typedef int Count。D:\PCLint\MyTest\Test1\(20): error 534: (Warning Ignoring return value of function 39。 fclose(fp)。 i6。will result in Info 825 on case 3 because control is falling through from the statement above,which is neither a case nor a default. The cure is to use the fallthrough option:case 1:case 2: n = 0。D:\PCLint\MyTest\Test1\(5): error 54: (Error Division by 0)int n = foo(4,0)。}PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ char a = 128。 printf(a)。 return 0。 *p。b39。 */ if( *p == 39。 int previous = 39。D:\PCLint\MyTest\Test1\(9): error 54: (Error Division by 0)D:\PCLint\MyTest\Test1\(9): error 414: (Warning Possible division by 0 [Reference: file D:\PCLint\MyTest\Test1\: line 9])}D:\PCLint\MyTest\Test1\(10): error 529: (Warning Symbol 39。s Visual C/C++, Version 4 Microsoft39。用+cpp標識C++文件擴展名:lin +cpp(cc) 、++模塊處理。s Visual Studio 的配置文件lib....lnt 特定庫的配置文件au....lnt 作者推薦檢查項的配置文件,指Scott Meyers 的Effective C++,More Effective C++,Misra,Dan Saks 的C++ GotchasTest\... 測試代碼目錄配置,可用于檢查C/C++文件,使用方法:lin options file1 file2 …:InstDir\lintnt iConfDir amp。官方網(wǎng)站:PCLint第三方工具:Visual LintLintProject 安裝安裝后的目錄Lint 目錄下的文件: PClint 執(zhí)行程序 PClint 配置程序 幫助手冊的補充信息 幫助手冊 打印工具. PClint 的錯誤提示消息列