• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            S.l.e!ep.¢%

            像打了激速一樣,以四倍的速度運轉,開心的工作
            簡單、開放、平等的公司文化;尊重個性、自由與個人價值;
            posts - 1098, comments - 335, trackbacks - 0, articles - 1
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            pclint 升級和使用 [2]

            Posted on 2009-09-19 22:12 S.l.e!ep.¢% 閱讀(2618) 評論(1)  編輯 收藏 引用 所屬分類: test
            pclint 升級和使用 [2]
            2007-07-06 23:42

            安裝
            將壓縮包比如pclint8.zip拷貝到c:\,解壓后重命名目錄為c:\pclint

            不用任何配置,直接使用
            準備待被檢查的文件:
            先在E:\建一個文件:main.cpp,內容為:

            void main()
            {???
            }

            最簡單的用法
            在命令行下輸入:D:\>C:\PCLint\Lint-nt E:\main.cpp

            C:\PCLint>C:\PCLint\Lint-nt E:\main.cpp

            PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004

            --- Module:???? E:\main.cpp

            _

            }

            E:\main.cpp??? 3??? Info 783: Line does not end with new-line

            C:\PCLint>

            PCLINT已經工作了,是不是簡單的難以讓人相信。

            最簡單的標準用法
            修改被檢查的文件E:\main.cpp,內容修改為:
            #include <stdio.h>
            void main()
            {
            ????? printf("hello pclint\n");???
            }

            再次在命令行下輸入:D:\>C:\PCLint\Lint-nt E:\main.cpp
            D:\>lint
            PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004

            --- Module:???? E:\main.cpp
            ?????????? _

            #include <stdio.h>
            E:\main.cpp??? 1??? Error 322: Unable to open include file 'stdio.h'
            D:\>

            報錯誤,“不能找到頭文件stdio.h”
            當然PCLINT不可能也不應該知道到哪里去找stdio.h,stdio.h所在的路徑需要我們告訴它。
            如何告訴呢?
            通常的做法是在xxx.lnt文件中指定,然后指定使用這個xxx.lnt文件。
            最簡單的是使用 c:\pclint\std.lnt 這個文件。

            std.lnt的配置:
            修改std.lnt
            運行C:\PCLint\CONFIG.EXE(或者直接手工修改std.lnt)

            最后生成的std.lnt內容為:

            //??? Microsoft C and Visual C++ 6.x, -si4 -sp4,

            //??? Standard lint options

            co-msc60.lnt

            // options.lnt??? -si4 -sp4

            -i"E:\Program Files\Microsoft Visual Studio\VC98\Include"

            -i"E:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE"

            -i"E:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE"

            暫時將options.lnt 這行注釋掉。
            注:如果生成的std.lnt內容與上面不一樣,可以手工修改成上面那樣。

            使用std.lnt
            再次在命令行下輸入:D:\> C:\PCLint\Lint-nt -i"C:\PCLint" -u std.lnt e:\main.cpp

            C:\PCLint\Lint-nt -i"C:\PCLint" -u std.lnt e:\main.cpp

            -i"C:\PCLint" -u std.lnt 指明使用std.lnt這個選項文件,至于std.lnt在什么目錄,通過-i"C:\PCLint"告知。

            至此,我們已經學會了PCLINT的簡單用法及兩個選項:-i,-u

            -i 指明包含路徑

            -u 指明使用哪些.lnt文件


            前面我們掌握了命令行方式下PCLINT的使用方法,下面介紹在VC下面的配置及使用。

            3.1. VC下的配置
            新建一自定義工具項,名稱為:PCLINT

            其中的Arguments為:-i"C:\PCLint" -u std.lnt env-vc6.lnt "$(FileName)$(FileExt)"

            Q:怎么知道要輸入這樣的參數了?

            A:從幫助中得知的,見文件env-vc6.lnt

            Q: env-vc6.lnt有什么作用?

            A:指定輸出錯誤報告的格式,這個選項可以去掉,比如修改為:

            Arguments為:-i"C:\PCLint" -u std.lnt "$(FileName)$(FileExt)"

            3.2. 示例
            3.2.1.????? testForPclint1
            新建一個最簡單的Win32 Console Application,工程名testForPclint1,其中的main.cpp為:

            void main()

            {???

            }

            點擊Tools菜單下面的PCLINT菜單項:

            PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004

            --- Module:???? main.cpp

            }

            main.cpp(3): error 783: (Info -- Line does not end with new-line)

            --- Global Wrap-up

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

            Press any key to continue

            第三行有個錯誤:error 783: (Info -- Line does not end with new-line)

            意思是說沒有以新行結束。

            注:如果Arguments為:-i"C:\PCLint" -u std.lnt "$(FileName)$(FileExt)"

            則結果為:

            PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004


            --- Module:???? main.cpp
            _

            }

            main.cpp(3) : Info 783: Line does not end with new-line

            Press any key to continue

            修改main.cpp為:

            void main()

            {???

            }<---即在這里加一個回車

            再次LINT,結果沒有任何告警:

            PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004

            --- Module:???? main.cpp
            --- Global Wrap-up
            error 900: (Note -- Successful completion, 0 messages produced)
            Press any key to continue

            3.2.2.????? testForPclint2
            新建一個最簡單的Win32 Console Application,工程名testForPclint2,其中的main.cpp為:

            #include "stdio.h"
            int main(int argc, char* argv[])
            {
            ????? printf("hello\n");
            }

            點擊Tools菜單下面的PCLINT菜單項:

            PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004

            --- Module:???? main.cpp
            _

            }

            main.cpp(6) : Warning 533: function 'main(int, char **)' should return a value

            ????? (see line 3)

            main.cpp(3) : Info 830: Location cited in prior message

            _

            }

            main.cpp(6) : Info 715: Symbol 'argv' (line 3) not referenced

            main.cpp(3) : Info 830: Location cited in prior message

            _

            }

            main.cpp(6) : Info 818: Pointer parameter 'argv' (line 3) could be declared as

            ????? pointing to const

            main.cpp(3) : Info 830: Location cited in prior message

            _

            }

            main.cpp(6) : Info 715: Symbol 'argc' (line 3) not referenced

            main.cpp(3) : Info 830: Location cited in prior message

            Press any key to continue

            有4個告警,修改main.cpp為:

            #include "stdio.h"
            int main(int argc, char* argv[])
            {
            ????? (void)argc; // pc lint
            ????? (void)argv; // pc lint
            ????? printf("hello\n");
            ????? return 0;
            }


            再次LINT,無任何告警了。

            PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004

            --- Module:???? main.cpp
            Press any key to continue

            4.???? 使用批處理方法
            為什么要使用批處理?還不是為了使用更簡單。

            我們在C:\PCLint建一個批處理文件lint.bat,內容為:
            @echo off
            C:\PCLint\Lint-nt -i"C:\PCLint" -u std.lnt e:\main.cpp

            為了支持輸入參數,修改為:
            @echo off
            C:\PCLint\Lint-nt -i"C:\PCLint" -u std.lnt %1

            這時候我們不能簡單輸入D:\>lint.bat,而必須加上輸入參數:

            D:\>lint.bat e:\main.cpp

            ////////////////////////

            二,pc??? lint??? 在幾個編譯器的配置???
            ??????
            ?? 人云亦云實在不是個好行為-----網絡上都那樣一致的說法讓我走了不少彎路??? 。?????
            ??????
            ??????
            ?? 好了言歸正傳,開始配置pc??? lint??? .?????
            ??????
            ?? 以下假設您已經把pc??? lint??? 安裝在C盤下(c:\pclint)???
            ?? (其他目錄也可以)???
            ??????
            ?? 我們不必要將c:\pclint\lnt??? 下的???
            ?? 3個文件lib-w32.lnt,env-vc6.lnt,co-msc60.lnt拷貝至c:\pclint下,???
            ?? 那樣簡直是擾亂視線,而且還會引起麻煩??? ;???
            ??????
            ?? 也不必在安裝目錄下創建std.lnt和options.lnt兩個文件??? !???
            ??????
            ?? 因為我要設置VC6,??? Source??? Insight??? 及Keil??? C51等編譯器,???
            ??????
            ?? 所以不是一個std.lnt就能解決問題的??? !???
            ??????
            ?? 我的做法是:??? 一類編譯器一個lnt文件,基本屬于"不動產" .?????
            ?? e.g.??? :?????
            ?? vc6_0.int???????
            ?? //??? vc6_0.int??? content??? for??? VC6??? .???
            ?? //************************************************************************???
            ?? //************************************************************************???
            ??????
            ????
            ?? //??? compile??? environment???
            ?? c:\pclint\lnt\env-vc6.lnt???
            ??????
            ????
            ?? //??? system??? lib??? include??? .???
            ?? c:\pclint\lnt\co-msc60.lnt???
            ?? c:\pclint\lnt\lib-w32.lnt???
            ??????
            ????
            ?? //??? system??? stdio??? hearder??? files??? directory??? .???
            ?? -i"D:\Program??? Files;D:\Program??? Files\Microsoft??? Visual??? Studio\VC98\Include"???
            ??????
            ????
            ?? //??? user's??? defined??? lint??? configure??? file??? .???
            ?? G:\work\eva_skype\eva_skype_pc\vc.lnt??? -si4??? -sp4???

            si3_5.int???????
            ?? //??? si3_5.int??? content??? for??? Source??? Insight??? .???
            ?? //************************************************************************???
            ?? //************************************************************************???
            ??????
            ????
            ?? //??? compile??? environment??? .???
            ?? c:\pclint\lnt\env-si.lnt???
            ??????
            ????
            ?? //??? system??? lib??? include??? .???
            ?? c:\pclint\lnt\co-msc60.lnt???
            ?? c:\pclint\lnt\lib-w32.lnt???
            ??????
            ????
            ?? //??? system??? stdio??? hearder??? files??? directory??? .???
            ?? -i"D:\Program??? Files;D:\Program??? Files\Microsoft??? Visual??? Studio\VC98\Include"???
            ??????
            ????
            ?? //??? user's??? defined??? lint??? configure??? file??? .???
            ?? G:\work\eva_skype\handset\app\si.lnt??? -si4??? -sp4???
            ??????
            ????
            ?? //************************************************************************???
            ?? //************************************************************************???
            ??????
            ??????
            ??????
            ??????
            ?? kc51.lnt???
            ?? //??? kc51.lnt??? content??? for??? Keil??? C51??? .???
            ?? //************************************************************************???
            ?? //************************************************************************???
            ??????
            ????
            ?? //??? compile??? environment??? .???
            ?? -i"c:\pclint\lnt\evn-keil.lnt"???
            ??????
            ????
            ?? //??? system??? lib??? include??? .???
            ?? c:\pclint\lnt\co-kc51.lnt???
            ??????
            ????
            ?? //??? system??? stdio??? hearder??? files??? directory??? .???
            ?? -i"D:\Program??? Files\EVA_KEILC51\C51\INC"???
            ??????
            ????
            ?? //??? user's??? defined??? lint??? configure??? file??? .???
            ?? G:\work\eva_skype\handset\kc.lnt??? -si4??? -sp4???

            久久国产亚洲精品| 中文字幕久久波多野结衣av| 麻豆亚洲AV永久无码精品久久| 18禁黄久久久AAA片| 久久久久99这里有精品10| 午夜视频久久久久一区| 亚洲?V乱码久久精品蜜桃 | 久久99精品久久久久久噜噜| 久久99热这里只有精品国产| 精品国产婷婷久久久| 性欧美大战久久久久久久 | 亚洲精品高清一二区久久| 久久综合久久综合亚洲| 亚洲国产精品久久电影欧美| 国内精品久久久久久久97牛牛| 日本久久久久久中文字幕| 伊人久久大香线蕉精品| 亚洲а∨天堂久久精品| 香蕉久久av一区二区三区| 久久99热精品| 欧美日韩中文字幕久久久不卡| 四虎久久影院| 2021久久国自产拍精品| 久久一区二区三区99| 国产亚洲精久久久久久无码| 久久夜色精品国产www| 亚洲AV无码久久精品成人| 免费一级做a爰片久久毛片潮| 亚洲第一极品精品无码久久| 欧美久久一区二区三区| 精品久久一区二区三区| 亚洲精品无码久久一线| 久久精品夜色噜噜亚洲A∨| 国产精品对白刺激久久久| 色综合久久中文字幕综合网| 国产午夜久久影院| 99蜜桃臀久久久欧美精品网站| 久久精品国产亚洲Aⅴ香蕉| 久久精品人成免费| 久久亚洲国产精品成人AV秋霞 | 国产亚洲成人久久|