Using an admittedly old compiler, I'm trying to compile code that uses functions like nan()
, swprintf()
, and other C99 features. I add the -std=c99
argument to CFLAGS, and those issues get fixed, but now I'm seeing
warning: implicit declaration of function ‘gmtime_r’
I tried following the advice in implicit declaration of function ‘gmtime_r’, but it didn't help.
Did gmtime_r()
get removed from C99 or something?
Here's a tiny test program:
#include <math.h>
#include <time.h>
int
main(int argc, char **argv)
{
double x;
time_t t;
struct tm tm;
x = nan("0");
t = time(NULL);
gmtime_r(&t, &tm);
return 0;
}
And the results of trying to compile it:
$ cc --version
cc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cc -c foo.c
foo.c: In function ‘main’:
foo.c:12: warning: incompatible implicit declaration of built-in function ‘nan’
$ cc -c -std=c99 foo.c
foo.c: In function ‘main’:
foo.c:14: warning: implicit declaration of function ‘gmtime_r’