共2条
1/1 1 跳转至页
今天看了PC-lint的东西,想再受一点打击,随便写写!

很久以前使用过PC-lint,整个代码被发现600多处waring,郁闷!
今天试了试8.0版本的,随便写一点,[color=#DC143C]好的工具是成功的一个关键![/color]
PC-Lint
C/C++静态分析工具
--------------------------------------------------
1.支持的C/C++语言标准
C:K&R/ANSI
C++:ANSI/ISO
--------------------------------------------------
2.PC-Lint介绍
PC-Lint的作用大家都应该有所耳闻!我在这里应用PC-Lint的Help问当中的一句话:
PC-lint/FlexeLint finds quirks, idiosyncrasies, glitches and bugs in C and C++ programs.
总值一句话,PC-Lint可以做得比你所用的Compiler更严格的检查!
下面是Help里面的例子:
1:
2: char *report( short m, short n, char *p )
3: {
4: int result;
5: char *temp;
6: long nm;
7: int i, k, kk;
8: char name[11] = "Joe Jakeson";
9:
10: nm = n * m;
11: temp = p == "" ? "null" : p;
12: for( i = 0; i < m; i++ )
13: { k++; kk = i; }
14: if( k == 1 ) result = nm;
15: else if( kk > 0 ) result = 1;
16: else if( kk < 0 ) result = -1;
17: if( m == result ) return temp;
18: else return name;
19: }
我曾自己分析过这断程序,找出的Waring也不过3处!然后一看解释部分,结论是我的编程功夫还需要再好好的学!汗ing...
大家可以试一下用PC-Lint来分析!希望不要的出我那样的结论!
PC-Lint的C++检查是主要针对有可能忽略的类型检查和大型编程的多模块冲突。(鉴于小弟对C++不是很熟悉,所以...)
--------------------------------------------------
3 安装
过程(略)......(不会有人拿鸡蛋丢我吧?)
--------------------------------------------------
4 设置
在开始菜单中运行PC-lint/Configuration Wizard!
在设置的过程中,需要选择PC-lint的配置文件STD.lnt或者其他的STD_X.lnt等的,还需要设置头文件目录等信息!
-------------------------------------------------
5 例子
D:\Lint>lin filea.cpp fileb.cpp(这是需要你键入的,以下的都是输出的了)
D:\Lint>"D:\Lint\Lint-nt" +v -i"D:\Lint" std.lnt -os(_LINT.TMP) filea.cpp f
ileb.cpp
PC-lint for C/C++ (NT) Ver. 8.00h, Copyright Gimpel Software 1985-2002
--- Module: filea.cpp
--- Module: fileb.cpp
D:\Lint>type _LINT.TMP | more
--- Module: filea.cpp
--- Module: fileb.cpp
_
};
fileb.cpp 5 Warning 631: tag 'X' defined differently at line 4, file
filea.cpp
--- Global Wrap-up
Warning 1527: static member 'X::a' (line 6, file filea.cpp) not defined
---
output placed in _LINT.TMP
D:\Lint>
#######################################
第二个例子
D:\Lint>lin -itest \test\test1.lnt(这是需要你键入的,以下的都是输出的了)
D:\Lint>"D:\Lint\Lint-nt" +v -i"D:\Lint" std.lnt -os(_LINT.TMP) -itest \tes t\test1.lnt PC-lint for C/C++ (NT) Ver. 8.00h, Copyright Gimpel Software 1985-2002
--- Module: test\module1.cpp
--- Module: test\module2.c D:\Lint>type _LINT.TMP | more --- Module: test\module1.cpp --- Wrap-up for Module: test\module1.cpp Info 753: local class 'X' (line 7, file test\module1.cpp) not referenced
test\module1.cpp 7 Info 830: Location cited in prior message --- Module: test\module2.c _ { test\module2.c 3 Error 18: Symbol 'alpha(int)' redeclared (Arg. no. 1: signed/unsigned,precision) conflicts with line 4, file test\module1.cpp test\module1.cpp 4 Info 830: Location cited in prior message { test\module2.c 3 Warning 516: 'Symbol alpha(unsigned long)' has arg. type conflict (arg. no. 1 -- unsigned long vs. int) with line 4, file test\module1.cpp test\module1.cpp 4 Info 830: Location cited in prior message return (unsigned) l >> 16; test\module2.c 4 Warning 572: Excessive shift value (precision 16 shifted right by 16) --- Global Wrap-up Info 1714: Member function 'X::f(int)' (line 9, file test\module1.cpp) not referenced test\module1.cpp 9 Info 830: Location cited in prior message --- output placed in _LINT.TMP
D:\Lint
未完,待续......
关键词: 今天 看了 PC-lint 东西 想再 一点 打击
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【EEPW电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 |