c语言代码查错软件,Ubuntu下面的C语言代码检查工具 Splint
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
看一下下面的代码(当然包括错误,以检验splint的功能):
#include
int main(int argc,char* argv[]){
int a=100; /*没有使用的变量*/
int b[8];
printf("Hello c\n");
b[9]=100; /*明显数组越界 */
/* 用到了两个为声明的变量c和d/
c=100;
d=10;
return 0;
}
现在可以用splint来检查一下,为了检验是否可以检测到数组越界,使用+bounds选项。
splint hi.c +bounds
输出结果:
hi.c: (in function main)
hi.c:9:2: Unrecognized identifier: c
Identifier used in code has not been declared. (Use -unrecog to inhibit
warning)
hi.c:10:2: Unrecognized identifier: d
hi.c:4:6: Variable a declared but not used
A variable is declared but never used. Use /*@unused@*/ in front of
declaration to suppress message. (Use -varuse to inhibit warning)
hi.c:7:2: Likely out-of-bounds store:
b[9]
Unable to resolve constraint:
requires 7 >= 9
needed to satisfy precondition:
requires maxSet(b @ hi.c:7:2) >= 9
A memory write may write to an address beyond the allocated buffer. (Use
-likely-boundswrite to inhibit warning)
hi.c:3:14: Parameter argc not used
A function parameter is not used in the body of the function. If the argument
is needed for type compatibility or future plans, use /*@unused@*/ in the
argument declaration. (Use -paramuse to inhibit warning)
hi.c:3:25: Parameter argv not used
Finished checking --- 6 code warnings
现在详细看一下结果:
检查结果1:
hi.c:9:2: Unrecognized identifier: c
Identifier used in code has not been declared. (Use -unrecog to inhibit
warning)
hi.c:10:2: Unrecognized identifier: d
hi.c:4:6: Variable a declared but not used
A variable is declared but never used. Use /*@unused@*/ in front of
declaration to suppress message. (Use -varuse to inhibit warning)
这些应该是splint检测到变量c和d没有声明。
检查结果2:
hi.c:7:2: Likely out-of-bounds store:
b[9]
Unable to resolve constraint:
requires 7 >= 9
needed to satisfy precondition:
requires maxSet(b @ hi.c:7:2) >= 9
A memory write may write to an address beyond the allocated buffer. (Use
-likely-boundswrite to inhibit warning)
这些是检查存在数组越界,因为吧b[8]的最大数组序号应该是7,而不是9,所以出现requires 7 >= 9;
检查结果3:
hi.c:3:14: Parameter argc not used
A function parameter is not used in the body of the function. If the argument
is needed for type compatibility or future plans, use /*@unused@*/ in the
argument declaration. (Use -paramuse to inhibit warning)
hi.c:3:25: Parameter argv not used
这些表明argc和argv变量声明了,但是没有使用。这个不是什么问题。
如果小心使用splint,应该对于c语言的程序编写有非常大的辅助作用!
c语言代码查错软件,Ubuntu下面的C语言代码检查工具 Splint相关推荐
- ubuntu下c语言编程工具,Ubuntu系统下C语言代码检查工具(Splint)
看一下下面的代码(当然包括错误,以检验splint的功能): #include int main(int argc,char* argv[]){ int a=100; /*没有使用的变量*/ int ...
- Ubuntu 下使用go语言调用ffmpeg推流
Ubuntu 下使用go语言调用ffmpeg推流Ubuntu 下使用go语言调用ffmpeg推流 win10 安装 Ubuntu Windows Subsystem for Linux(WSL)适用于 ...
- 如何检查java代码有误_Java代码查错题
Java代码查错题: 1. abstractclassName { privateString name; publicabstractbooleanisStupidName(String name) ...
- ubuntu下使用反编译apk,工具dex2jar和jd-gui
ubuntu下使用反编译apk, 工具 1.首先使用dex2jar反编译 下载地址(建议下载最新版本,防止出现bug):http://code.google.com/p/dex2jar/downloa ...
- Win7旗舰版64位系统下怎样使用磁盘修复检查工具?
应该有很多人都知道在win7系统下自带的磁盘修复工具,是一款非常实用的修复工具,当win7系统出现系统故障时,一般都可以使用这款修复工具来修复,那要怎么使用这个工具呢?下面就由小编来告诉大家吧. 使用 ...
- ubuntu下编写C语言程序
目录 一.gcc编译C语言程序 二.makefile编译C语言程序 三.编译过程中遇到的问题 题目:编写一个主程序文件main1.c和一个子程序文件sub1.c,有如下要求:子程序sub1.c包含一个 ...
- ubuntu下创建c语言程序之hello world
将要学习c语言了,先记录一下在ubuntu下,使用vim创建一个最基本的hello world程序: 打开终端,使用cd命令转到操作的目录,如我在home下的program files文件内创建, 就 ...
- linux系统最好的c类语言开发软件,Linux下基于C 语言开发即时通信软件.doc
Linux下基于C 语言开发即时通信软件 Linux下基于C++语言开发即时通信软件 关键词:聊天软件 文字聊天 Linux平台 C/S架构ICE中间件 Linux-based instant mes ...
- Ubuntu下使用中文语言
参考自:点击打开链接 方式一: (1)点击System Settings (2)选择Language Support, (3)点击install安装语言包,选择简体中文,点击apply,等着安装完 ( ...
最新文章
- debian10 raid5+lvm
- Meta标签中的format-detection属性及含义
- git的团队协作开发
- 用二分类神经网络估算多分类神经网络迭代次数的经验公式
- 2.18-2.20 特殊权限和软硬链接
- Windows Mobile (EVC)开发手记1
- 三、在应用中升级----网络编程部分
- 阿里云服务器如何选配?
- 软工实践练习一——使用Git进行代码管理心得
- Java面试10大知识点总结宝典助你通关!已拿意向书!
- 经典面试题(26):以下代码将输出的结果是什么?
- 乐优商城(01)--项目启动
- dw写HTML怎么设置背景颜色,dreamweaver cs6设置div背景颜色的具体操作教程
- 计算机网络的最大优点,什么是计算机网络最突出的优点
- 真实渗透改编--综合渗透 sql注入写马+文件上传+udf提权 安鸾靶场SQL注入学习
- 【渝粤教育】国家开放大学2019年春季 0553-22T色彩 参考试题
- 仿企查查、天眼查关系图以及架构图(双向树,集团图谱,组织架构图谱,企业图谱,网络拓扑,人物关系网络)
- python爬取股票新闻
- n的阶乘怎么用计算机语言表示,python中阶乘的表示方法
- Python可视化 | Seaborn02