• 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的,因此这样的比较由于数据类型限制了它的范围,因此也就给出了警告。

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

  • 相关阅读:
    Python自动化开发-基础语法
    Python自动化开发-简介
    Hello World!
    Mongo导出数据文件导致错误 Got signal: 6 (Aborted)解决方法
    PHP快速排序及其时间复杂度
    PHP读某一个目录下所有文件和文件夹
    PHP获得两个绝对路径的相对路径
    awk神器
    PHP使用Mysql事务
    PHP使用session_set_save_handler陷阱
  • 原文地址:https://www.cnblogs.com/flying06/p/3843083.html
Copyright © 2020-2023  润新知