Search code examples
cmathfloor

floor of double(time_t)


I cannot understand why this throws undefined reference to `floor'":

double curr_time = (double)time(NULL);
return floor(curr_time);

Hasn't it been casted to double, which is what floor receives?


Solution

  • You possibly have run in to the infamous -lm problem: Compile as:

    gcc yourfile.c -o out -lm 
    

    This is C FAQ 14.3 item as well.