switch语句: 编译错误case label does not reduce to an integer constant

1、switch语句: 编译错误case label does not reduce to an integer constant

在case中肯定不能进行条件判断.
用嵌套的if else 就解决了

 

switch语句的格式为
switch(表达式)
{
  case 常量表达式1:  语句1
  case 常量表达式2:  语句2
  ^^^^^
  case 常量表达式n:  语句n
  default:          语句n+1
}

2、atoi: warning: passing arg 1 of `atoi' makes pointer from integer without a cast

make pointer from integer without a cast 的意思是:使指针指向一个整数型数据缺少一个指向
  这类问题大多是函数原参数指定是一个int整型的变量
    但是调用时却变成了其他类型的变量了,比如字符型
   这时要改变参数类型,至少也要做个强制类型转换。

 

3、`O_CREAT' undeclared (first use in this function)

man open 然后加上头文件解决

       #include <sys/types.h>
       #include <sys/stat.h>
       #include <fcntl.h>

4、warning: implicit declaration of function `close'

man close

#include <unistd.h>

5、 可能和sprintf有关

#include<stdio.h>
#include<string.h>

6、comparison is always true due to limited range of data type

   警告原因:有可能你定义了unsigned int uParam;但是你去做了if(uparam<0)的判断,

因为unsigned int 型的数据总是>=0的,因此这样的比较由于数据类型限制了它的范围,因此也就给出了警告。

 解决方法:可以去掉这样的判断。

转载于:https://www.cnblogs.com/flying06/p/3843083.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值