函数abs的隐式声明 - gcc-5.1.0 Implicit declaration of function abs - gcc-5.1.0
The abs() function is declared in <stdlib.h> which you've not included. abs()函数在<stdlib.h>声明,你没有包含它。 fabs() function is declared in <math.h>
函数abs的隐式声明 - gcc-5.1.0
Implicit declaration of function abs - gcc-5.1.0
Compiling the following code using gcc-5.1.0 produces a warning: 使用gcc-5.1.0编译以下代码会产生警告:
warning: implicit declaration of function ‘abs’ [-Wimplicit-function-declaration]
Code: 码:
#include <stdio.h>
#include <math.h>
int main (void)
{
printf ("%d\n", abs (-1));
return 0;
}
I have compiled the same code with gcc-4.9.2 and it's not producing any warning. 我用gcc-4.9.2编译了相同的代码,并没有产生任何警告。
The abs()
function is declared in <stdlib.h>
which you've not included. abs()
函数在<stdlib.h>
声明,你没有包含它。
GCC 4.9.2 didn't complain because the default compilation mode was C89/C90 ( -std=gnu89
) and functions did not need to be declared before being used in C89 as long as they returned an int
, but the default compilation mode was changed to C11 ( -stdd=gnu11
) in GCC 5.1.0 (see the release notes ) and in C11 functions must be declared (or defined) before they are used. GCC 4.9.2没有抱怨,因为默认编译模式是C89 / C90( -std=gnu89
),并且只要它们返回一个int
,就不需要在C89中使用之前声明函数,但默认的编译模式是在GCC 5.1.0中更改为C11( -stdd=gnu11
)(参见发行说明 ),在使用之前必须声明(或定义)C11函数。
Try to include the <stdlib.h>
in your code. 尝试在代码中包含<stdlib.h>
。 The abs()
function is defined inside the <stdlib.h>
abs()
函数在<stdlib.h>
定义
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2021-07-20 0709
2021-07-20 0708
2021-07-20 sqlDoc
2021-07-20 Android 调试桥 (adb)
2021-07-20 用adb录制手机屏幕视频
2021-07-20 android - 错误:This class should provide a default constructor (a public constructor with no arguments) [Instantiatable] in Android
2021-07-20 QueryRfidAssets