我有以下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中有以下代码:
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)
是什么原因以及如何解决?