ABS包括math.h中后'隐式声明...“错误 [英] abs 'implicit declaration...' error after including math.h
问题描述
我用 ABS()
功能,我加入的#include<文件math.h>
上方的code。不过,我不断收到此错误:
I used the abs()
function and I added #include <math.h>
at the top of code. But I keep getting this error:
hello.c:20:11: warning: implicit declaration of function 'abs' is invalid in C99
[-Wimplicit-function-declaration]
int a = abs(arrOfHour[i] - hour) * 60 + minute;
^
我使用LLVM编译器。
I'm using LLVM compiler.
为什么即使我已经包含发生此错误文件math.h
?
Why does this error occurs even though I have included math.h
?
推荐答案
我要在文档直引号:的\"Prototypes于ABS,实验室和llabs在stdlib.h中
I'm going to quote straight from the docs : "Prototypes for abs, labs and llabs are in stdlib.h"
作为一个经验法则,关于浮点数操作的数学函数是在math.h中,并且对整数操作的是stdlib.h中
As a rule of thumb the mathematical functions that operate on floating point numbers are in math.h, and the ones that operate on integers are in stdlib.h.
有一个 pretty良好的维基百科文章基于C数学函数,如果您需要了解更多信息。
There's a pretty good Wikipedia article on C mathematical functions if you need more information.
这篇关于ABS包括math.h中后'隐式声明...“错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!