我有以下的C代码:
当我编译这个程序时,我收到以下警告:
我对C语言有点生疏,但我认为#include将round()的声明引入了作用域。我已经查过了我的ANSI标准(我只有C99的副本),它证实round()函数存在于math.h头文件中。我错过了什么吗?
编辑:编译器是Ubuntu上的GCC 4.3.2(intrepid,如果我没记错)。运行gcc -E命令会显示:
所以很明显在头部找不到定义。
#include <math.h>
int main(int argc, char ** argv)
{
double mydouble = 100.0;
double whatever = round(mydouble);
return (int) whatever;
}
当我编译这个程序时,我收到以下警告:
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’
我对C语言有点生疏,但我认为#include将round()的声明引入了作用域。我已经查过了我的ANSI标准(我只有C99的副本),它证实round()函数存在于math.h头文件中。我错过了什么吗?
编辑:编译器是Ubuntu上的GCC 4.3.2(intrepid,如果我没记错)。运行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);
所以很明显在头部找不到定义。
round()
函数(当然编译器可以作为扩展提供它)。 - pmg