相关疑难解决方法(0)

为什么gcc报告"隐含的函数声明'轮''?

我有以下C代码:

#include <math.h>

int main(int argc, char ** argv)
{
    double mydouble = 100.0;
    double whatever = round(mydouble);

    return (int) whatever;
}
Run Code Online (Sandbox Code Playgroud)

当我编译它时,我收到警告:

round_test.c: In function ‘main’:
round_test.c:6: warning: implicit declaration of function ‘round’
round_test.c:6: warning: incompatible implicit declaration of built-in function ‘round’
Run Code Online (Sandbox Code Playgroud)

我对C生锈了,但我认为#include将round()的声明带入了范围.我已经检查了我的ANSI标准(C99是我唯一的副本),它确认了math.h标题中存在round()函数.我在这里错过了什么?

编辑:编译器是Ubuntu上的GCC 4.3.2(intrepid,IIRC).运行gcc -E给出:

$ gcc -E round_test.c | grep round
# 1 "round_test.c"
# 1 "round_test.c"
# 2 "round_test.c" 2
    double whatever = round(mydouble);
Run Code Online (Sandbox Code Playgroud)

所以这个定义显然没有在标题中找到.

c gcc compiler-warnings

8
推荐指数
1
解决办法
3万
查看次数

使用isxdigit()时如何处理C中的数组下标警告?

我在C中有以下代码:

char input[127] = "hello world";

isxdigit(input[0]);
Run Code Online (Sandbox Code Playgroud)

但是我收到了以下警告:

warning: array subscript has type 'char'
Run Code Online (Sandbox Code Playgroud)

是什么原因以及如何解决?

c arrays ctype compiler-warnings

3
推荐指数
1
解决办法
920
查看次数

标签 统计

c ×2

compiler-warnings ×2

arrays ×1

ctype ×1

gcc ×1