【正文】
23在宏定義中添加Options屏蔽檢查:define for /*lint e(506, 774)*/if(0) {} else for例3:If you are usingdefine TRUE !0you will receive the message:506 Constant Value Booleanwhen TRUE is used in an arithmetic expression. (For C, TRUE should be defined to be 1. However, other languages use quantities other than 1 so some programmers feel that !0 is playing it safe.) To suppress this message for just this context you can use:define TRUE /*lint save e506 */ (!0) \/*lint restore */or the equivalent:emacro(506, TRUE)include define TRUE !0//define TRUE /*lint e506*/ (!0) /*lint restore*/int main(){ bool a = 1。 if (a == TRUE) printf(OK!\n)。 else printf(OK?\n)。 return 0。}PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ if (a == TRUE)D:\PCLint\MyTest\Test1\(9): error 506: (Warning Constant value Boolean) Global Wrapup error 900: (Note Successful pletion, 1 messages produced)Tool returned code: 1或者在Opetions文件中使用:emacro(506, TRUE)例4:使用lint save和lint restoreinclude define TRUE !0int main(){ bool a = 1。 //lint save e506 if (a == TRUE) printf(OK!\n)。 else printf(OK?\n)。 //lint restore bool b=1。 if(b==TRUE) {} return 0。}錯(cuò)誤禁止選項(xiàng)例子:禁止規(guī)則720:lint e720 禁止除1526外的所有規(guī)則:lint e???? +e1526 禁止這些規(guī)則的應(yīng)用:指針沖突、未賦值的參數(shù)、alpha未定義lint epp eau esym(526,alpha) will inhibit errors arising from pointerpointer clashes and unsigned arguments and will suppress plaints about alpha not being defined.eppeauesym例:/*lint esym( 530, a )*/include void main(){ char *a。 //char *a = hello world!\n。 printf(a)。}指定變量類(lèi)型大小The separate setting of these parameters is not normally necessary as the default settings are consistent with most pilers in your environment. Use the size options for specifying architectures other than the native architectures. For example, if you are linting for an embedded system where int and pointers are normally 16 bits you should specifylint si2 sp2 ...si4 // integers are 4 bytessp4 // pointers are 4 bytes too.1TB=1024GB 1GB=1024MB 1MB=1024KB 1KB=1024字節(jié)1字節(jié)=8位(bit)打印交互過(guò)程信息打印每個(gè)模塊、頭文件、每個(gè)選項(xiàng)的交互信息:lint +vof file1 file2 temp例如:PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ Line 1: Option: +vof Including file D:\PCLint\MyTest\Test1\ (hdr) Line 1: Option: +vof Including file D:\PCLint\MyTest\Test1\ (hdr) Including file C:\Program Files\Microsoft Visual Studio\VC98\Include\ (library) Including file C:\Program Files\Microsoft Visual Studio\VC98\Include\ (library) Module: D:\PCLint\MyTest\Test1\ Module: D:\PCLint\MyTest\Test1\ Line 0: Option: +rw(__inline) Including file D:\PCLint\MyTest\Test1\ (hdr) Line 0: Option: +rw(__inline) Including file D:\PCLint\MyTest\Test1\ (hdr) Including file C:\Program Files\Microsoft Visual Studio\VC98\Include\ (library) Including file C:\Program Files\Microsoft Visual Studio\VC98\Include\ (library) Global Wrapup error 900: (Note Successful pletion, 0 messages produced)Tool returned code: 0標(biāo)記選項(xiàng)(Flags)fpn例如,對(duì)于下面代碼,如果fpn標(biāo)記設(shè)置為ON,所有指針參數(shù)都被假設(shè)可能為NULL://lint +fpninclude void f( char *p, char *q ){ *p = 3。 // warning only if +fpn q++。 // warning only if +fpn}void g( char *p, char *q ){ if( p amp。amp。 q ) { *p = 3。 // no warning q++。 // no warning }}fcufcu CharisUnsigned flag (default OFF).Options: +fcu fcu ++fcu fcuIf this flag is ON, plain char declarations are assumed to be unsigned. This is useful for pilers, which, by default, treat char as unsigned. Note that this treatment is specifically allowed by the ANSI standard. That is, whether char is unsigned or signed is up to the implementation.例:include void main(){ char a = 128。}PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ char a = 128。D:\PCLint\MyTest\Test1\(5): error 569: (Warning Loss of information (initialization) (8 bits to 7 bits))}D:\PCLint\MyTest\Test1\(6): error 529: (Warning Symbol 39。a39。 (line 5) not subsequently referenced) Global Wrapup error 900: (Note Successful pletion, 2 messages produced)Tool returned code: 2修改為://lint +fcuinclude void main(){ char a = 128。}char 可能是signed char,也可能是unsigned char。這個(gè)取決于你的編譯器。如果是signed char ,8位的話取值范圍是128..127 ,而unsigned char 的取值范圍是0..255fdi消息展現(xiàn)選項(xiàng)Height選項(xiàng)h[s][F][f][a][b][r][mn][m][m/M/][I]NThe default height option is ha_3例1:hb^4例2:hb^3例3:h$2例4:h1The optional mn requests No Macro display. Normally, the value of each open macro at the time of the error is shown on a separate line, provided the message height (. the value of N) is at least 3. The line is by default prefixed with ....include define foo(a,b) ((a)/(b)+3)int n = foo(4,0)。PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ ... ((4)/(0)+3)int n = foo(4,0)。D:\PCLint\MyTest\Test1\(5): error 54: (Error Division by 0)int n = foo(4,0)。D:\PCLint\MyTest\Test1\(5): error 414: (Warning Possible division by 0 [Reference: file D:\PCLint\MyTest\Test1\: line 5]) Global Wrapup error 900: (Note Successful pletion, 2 messages produced)Tool returned code: 2//lint hmninclude define foo(a,b) ((a)/(b)+3)int n = foo(4,0)。PClint for C/C++ (NT) Ver. , Copyright Gimpel Software 19852001 Module: D:\PCLint\MyTest\Test1\ int n = foo(4,0)。D:\PCLint\MyTest\Test1\(6): error 54: (