求教:gcc 编译时候 sqrt 函数警告的问题
发表于 : 2011-03-17 11:36
代码:
编译命令:
编译结果:
不知为什么会出现这个警告,去查了下,都说不是没有包含math.h 就是编译时没有-lm选项,但是我都有阿,为什么还会出现这种警告呢?谢谢。。
代码: 全选
#include<stdio.h>
#include<math.h>
int main(void)
{
float a,b,c,s,area;
scanf("%f,%f,%f",&a,&b,&c);
s=1.0/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("a=%7.2f,b=%7.2f,c=%7.2f,s=%7.2f\n",a,b,c,s);
printf("area=%7.2f\n",area);
return 0;
}
代码: 全选
gcc -Wall test016_01.c -lm -o test016_01
代码: 全选
test016_01.c: In function ‘main’:
test016_01.c:16: warning: implicit declaration of function ‘sqrt’
test016_01.c:16: warning: incompatible implicit declaration of built-in function ‘sqrt’
Press ENTER or type command to continue