vc下proc开发环境与pclint的配置-pclint相关
2014-08-11 15:09
417 查看
另外,针对一些常见的警告或错误提示,做一个说明:
1、error 530: (Warning -- Symbol 'tmp' (line 643) not initialized)
这个很容易,根据提示说明,是变量定义后没有初始化,在变量定义时初始化就可以解决;
2、memcpy(&PriceInfo.sReportCode, aData, i);
svr_refhq.pc(377): error 545: (Warning -- Suspicious use of &)
由于系统函数memcpy的参数是指针,所以实际是要将sReportCode的地址作为参数传入,但目前的写法存在一些问题:
第一,这里的写法是取得PriceInfo的地址还是PriceInfo.sReportCode的地址?
第二,sReportCode本身是字符串,即字符数组,不带下标的时候就是表示的首字符,也即指针地址,所以再用 & 来取地址会取得指针的指针。
3、#define COLUMNS_MAX_LEN 1024
D:\mywork\O32\Sources\Src\svr_instruction\utils.h(14): error 760: (Info -- Redundant macro 'COLUMNS_MAX_LEN' defined identically at line 42, file d:\mywork\O32\Sources\Src\public\sstruction.h)
d:\mywork\O32\Sources\Src\public\sstruction.h(42): error 830: (Info -- Location cited in prior message)
这是由于在utils.h和sstruction.h里都定义了同一个名字COLUMNS_MAX_LEN的宏,根据提示redundant很容易知道,只要去掉utils.h里的定义就可以了。
4、 memset(&sSQL,0,sizeof(sSQL));
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(52): error 545: (Warning -- Suspicious use of &)
这个警告和第3点的类似,正确的做法:
sSQL char[1024];
初始化:sSQL[0]='0\';
这样初始化可以大大提高性能,对于大字符串尽量少用memset的方式,即使要用,也应该是:
memset(sSQL,0,sizeof(sSQL));
5、 iRet = CallServiceA("CallASARService", Sendbuff, GErrorMessage);
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(320): error 718: (Info -- Symbol 'CallServiceA' undeclared, assumed to return int)
这个错误是因为CallServiceA()只有spub.c里的实现,没有在spub.h里声明,不符合C语言的标准用法,通过在spub.h里增加声明解决。
6、 if (iUnApprove > 0 )
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(379): error 774: (Info -- Boolean within 'if' always evaluates to False [Reference: file D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc: lines 43, 379])
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(43): error 831: (Info -- Reference cited in prior message)
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(379): error 831: (Info -- Reference cited in prior message)
这一系列的错误是因为iUnApprove初始化时赋值为0,后面只有select语句里对该变量赋值,当用PCLINT对 .pc文件进行检查时,pclint无法识别该语句,因此会以为没有对iUnApprove赋值,始终为false。
需要改变一下做法,改为对 .c文件做检查。具体做法,在每个要检查的.pc文件的‘设置’中,在proc 命令行下面增加如下的命令行:
c:\pclint\lint-nt -u c:\pclint\lnt\std.lnt c:\pclint\lnt\env-vc6.lnt "$(InputDir)\$(InputName).c"
这样设置后,就不再需要用 工具里设置的pc lint来检查了。
1、error 530: (Warning -- Symbol 'tmp' (line 643) not initialized)
这个很容易,根据提示说明,是变量定义后没有初始化,在变量定义时初始化就可以解决;
2、memcpy(&PriceInfo.sReportCode, aData, i);
svr_refhq.pc(377): error 545: (Warning -- Suspicious use of &)
由于系统函数memcpy的参数是指针,所以实际是要将sReportCode的地址作为参数传入,但目前的写法存在一些问题:
第一,这里的写法是取得PriceInfo的地址还是PriceInfo.sReportCode的地址?
第二,sReportCode本身是字符串,即字符数组,不带下标的时候就是表示的首字符,也即指针地址,所以再用 & 来取地址会取得指针的指针。
3、#define COLUMNS_MAX_LEN 1024
D:\mywork\O32\Sources\Src\svr_instruction\utils.h(14): error 760: (Info -- Redundant macro 'COLUMNS_MAX_LEN' defined identically at line 42, file d:\mywork\O32\Sources\Src\public\sstruction.h)
d:\mywork\O32\Sources\Src\public\sstruction.h(42): error 830: (Info -- Location cited in prior message)
这是由于在utils.h和sstruction.h里都定义了同一个名字COLUMNS_MAX_LEN的宏,根据提示redundant很容易知道,只要去掉utils.h里的定义就可以了。
4、 memset(&sSQL,0,sizeof(sSQL));
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(52): error 545: (Warning -- Suspicious use of &)
这个警告和第3点的类似,正确的做法:
sSQL char[1024];
初始化:sSQL[0]='0\';
这样初始化可以大大提高性能,对于大字符串尽量少用memset的方式,即使要用,也应该是:
memset(sSQL,0,sizeof(sSQL));
5、 iRet = CallServiceA("CallASARService", Sendbuff, GErrorMessage);
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(320): error 718: (Info -- Symbol 'CallServiceA' undeclared, assumed to return int)
这个错误是因为CallServiceA()只有spub.c里的实现,没有在spub.h里声明,不符合C语言的标准用法,通过在spub.h里增加声明解决。
6、 if (iUnApprove > 0 )
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(379): error 774: (Info -- Boolean within 'if' always evaluates to False [Reference: file D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc: lines 43, 379])
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(43): error 831: (Info -- Reference cited in prior message)
D:\mywork\O32\Sources\Src\svr_instruction\svr_instrcancel.pc(379): error 831: (Info -- Reference cited in prior message)
这一系列的错误是因为iUnApprove初始化时赋值为0,后面只有select语句里对该变量赋值,当用PCLINT对 .pc文件进行检查时,pclint无法识别该语句,因此会以为没有对iUnApprove赋值,始终为false。
需要改变一下做法,改为对 .c文件做检查。具体做法,在每个要检查的.pc文件的‘设置’中,在proc 命令行下面增加如下的命令行:
c:\pclint\lint-nt -u c:\pclint\lnt\std.lnt c:\pclint\lnt\env-vc6.lnt "$(InputDir)\$(InputName).c"
这样设置后,就不再需要用 工具里设置的pc lint来检查了。
相关文章推荐
- vc下proc开发环境与pclint的配置-VC下proc开发
- vc下proc开发环境与pclint的配置-设置识别pc代码
- Windows下的Gtk+开发环境配置(vc)
- VC++ 6.0下OpenGL开发环境配置
- VC6.0配置Proc开发环境:
- VC DirectShow开发环境变量配置及问题
- Windows下的Gtk+开发环境配置(vc)
- 如何在VC中配置winPcap开发环境
- VS 2008中PDA开发环境的相关配置
- WDK(7600.16385.1) + VC6 驱动开发环境配置
- VC6下开发OCCI程序的环境配置
- vc++ for symbian 开发环境配置 经验总结
- VC开发GTK配置环境
- VC++ 6.0下OpenGL开发环境配置
- VC 6中配置OpenGL开发环境
- VC6下开发OCCI程序的环境配置
- 汇编语言新手入门:VC2008 环境下汇编语言开发环境的配置,支持Visual Assist
- VS 2008中PDA开发环境的相关配置。
- ubuntu11.10 配置 python 相关开发环境
- VC Directsound开发环境配置