KeilMDK编译警告:warning: #514-D: pointless comparison of unsigned integer with a negative constant
2015-06-02 12:02
731 查看
编译包含下面一段代码的程序,代码如下:
web_server.c(288): warning: #514-D: pointless comparison of unsigned integer with a negative constant
大意为:一个无意义的比较在无符号整型和一个负数常量
查找原因发现:发现 cmd 变量定义形式为:
unsigned char cmd;
解决办法如下:
把 不同类型的-1 强制类型转换后的结果为多少?
if (cmd == -1) { plen=fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 401 Unauthorized\r\nContent-Type: text/html\r\n\r\n<h1>401 Unauthorized</h1>")); goto SENDTCP; }编译结果针对这行,做出如下警告:
web_server.c(288): warning: #514-D: pointless comparison of unsigned integer with a negative constant
大意为:一个无意义的比较在无符号整型和一个负数常量
查找原因发现:发现 cmd 变量定义形式为:
unsigned char cmd;
解决办法如下:
if (cmd == (unsigned char)-1) { plen=fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 401 Unauthorized\r\nContent-Type: text/html\r\n\r\n<h1>401 Unauthorized</h1>")); goto SENDTCP; }可以思考的问题:
把 不同类型的-1 强制类型转换后的结果为多少?
相关文章推荐
- 一些对比
- HDFS基本文件常用命令
- hello world
- 【Android控件原理】控件View的绘制
- 七牛java-sdk生成token。
- PHP 中的新语法 new static 是个啥意思?
- Java多线程系列--“基础篇”11之 生产消费者问题
- 面试题31:连续子数组最大的和
- AsyncSocket的使用
- Spring MVC 跳转相关
- 考研计算机专业课计数器控制循环的要点
- 考研计算机专业课自增和自减运算符
- linux下重启oracle数据库
- Java动态代理机制详解(JDK 和CGLIB,Javassist,ASM)
- 第十三周(动物这样叫)
- Hadoop大数据批处理 -Map/Reduce
- Orchard创建全局应用
- 考研计算机专业课赋值运算符
- 如何解决crontab脚本执行sudo
- discuz 论坛UCenter无法登录,闪退的终极8种解决办法