at the top of the code. But I keep g...">

Abs "implicit declaration ..." after including math.h

I used the abs() function, and I added #include <math.h> at the top of the 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; ^ 

I am using the LLVM compiler.

Why does this error occur even though I included math.h ?

+8
c absolute-value
source share
1 answer

I am going to quote directly from the docs: "Prototypes for abs, labs and llabs are in stdlib.h"

Typically, math functions that work with floating point numbers are in math.h, and those that work with integers are in stdlib.h.

There's a pretty good Wikipedia article on C math functions if you need more information.

+18
source share

All Articles