linux鸟哥的私房菜中 gcc 加入链接库的时候出现的异常
linux鸟哥的私房菜中 gcc 加入链接库的时候出现的错误
这个是上面的代码,文件名就叫a.c好了
然后我
gcc a.c -lm -L/lib -L/usr/lib
但是 提示 隐式声明与内建函数 sin 不兼容。。。。。
what happens!!!!
------解决思路----------------------
#include <math.h>
------解决思路----------------------
使用数学函数了, 好像要使用 -math 把(好像是这样
)
------解决思路----------------------
warning: incompatible implicit declaration of built-in function
if that's the case and you don't want to include the header file, which will suppress the warning message, you can simply ignore the warning, your program is fine.
To explain why you got this warning:
in C language, a previously undeclared function is counted as an implicit declaration of the function and its return value is always with type int. For GCC, however, it has built-in definitions for some standard functions. If an implicit declaration does not match the built-in definition, you get this warning.
------解决思路----------------------
-lm 是链接选项,编译分为 预处理、编译、链接 几个阶段,这个错误是在编译阶段,头文件是在预处理阶段处理
#include<stdio.h>
int main(){
printf("value : %f \n",sin(3.14/2));
return 0;
}
这个是上面的代码,文件名就叫a.c好了
然后我
gcc a.c -lm -L/lib -L/usr/lib
但是 提示 隐式声明与内建函数 sin 不兼容。。。。。
what happens!!!!
------解决思路----------------------
#include <math.h>
------解决思路----------------------
使用数学函数了, 好像要使用 -math 把(好像是这样
------解决思路----------------------
warning: incompatible implicit declaration of built-in function
if that's the case and you don't want to include the header file, which will suppress the warning message, you can simply ignore the warning, your program is fine.
To explain why you got this warning:
in C language, a previously undeclared function is counted as an implicit declaration of the function and its return value is always with type int. For GCC, however, it has built-in definitions for some standard functions. If an implicit declaration does not match the built-in definition, you get this warning.
------解决思路----------------------
-lm 是链接选项,编译分为 预处理、编译、链接 几个阶段,这个错误是在编译阶段,头文件是在预处理阶段处理