Compiling GeneralizedTime.c fails on WSL/Ubuntu
Compiling GeneralizedTime.c on WSL/Ubuntu gives me the following errors:
cc -DASN_PDU_COLLECTION -I. -o GeneralizedTime.o -c GeneralizedTime.c
GeneralizedTime.c: In function ‘GeneralizedTime_encode_der’:
GeneralizedTime.c:247:12: error: storage size of ‘tm’ isn’t known
struct tm tm;
^~
GeneralizedTime.c: In function ‘GeneralizedTime_encode_xer’:
GeneralizedTime.c:281:13: error: storage size of ‘tm’ isn’t known
struct tm tm;
^~
GeneralizedTime.c: In function ‘GeneralizedTime_print’:
GeneralizedTime.c:314:13: error: storage size of ‘tm’ isn’t known
struct tm tm;
^~
GeneralizedTime.c: In function ‘asn_GT2time_frac’:
GeneralizedTime.c:370:12: error: storage size of ‘tm_s’ isn’t known
struct tm tm_s;
^~~~
GeneralizedTime.c:565:10: warning: implicit declaration of function ‘timegm’ [-Wimplicit-function-declaration]
tloc = timegm(&tm_s);
^~~~~~
GeneralizedTime.c:572:10: warning: implicit declaration of function ‘mktime’; did you mean ‘mktemp’? [-Wimplicit-function-declaration]
tloc = mktime(&tm_s);
^~~~~~
mktemp
GeneralizedTime.c:582:5: error: dereferencing pointer to incomplete type ‘struct tm’
*ret_tm = tm_s;
^~~~~~~
GeneralizedTime.c:584:8: warning: implicit declaration of function ‘gmtime_r’ [-Wimplicit-function-declaration]
if(gmtime_r(&tloc, ret_tm) == 0) {
^~~~~~~~
GeneralizedTime.c:590:7: warning: implicit declaration of function ‘localtime_r’ [-Wimplicit-function-declaration]
if(localtime_r(&tloc, ret_tm) == 0) {
^~~~~~~~~~~
GeneralizedTime.c: In function ‘asn_time2GT_frac’:
GeneralizedTime.c:611:12: error: storage size of ‘tm_s’ isn’t known
struct tm tm_s;
^~~~
GeneralizedTime.c:634:18: error: dereferencing pointer to incomplete type ‘const struct tm’
gmtoff = GMTOFF(*tm);
^~
GeneralizedTime.c:71:22: note: in definition of macro ‘GMTOFF’
#define GMTOFF(tm) ((tm).tm_gmtoff)
^~
Makefile:23: recipe for target 'GeneralizedTime.o' failed
make: *** [GeneralizedTime.o] Error 1
My time.h does not contain struct tm. Is there a way to fix it or a workaround?
Thanks,
Manually including </usr/include/time.h> in GeneralizedTime.c and UTCTime.c solved the issue as a workaround.
I am facing the same issue on windows. Do you know any workaround?
Manually including </usr/include/time.h> in GeneralizedTime.c and UTCTime.c solved the issue as a workaround.
That didn't work?
No it is giving no such file or directory
I checked my time.h file and I couldn't find any struct tm in it. Do I have to include this file separately from somewhere??
Unlikely. struct tm exists in both Cygwin, Mingw and Clang. I have no idea what compiler/environment you're using.
You're probably looking in sys/time.h and not usr/include/time.h.
What compiler are you using? Are you using a development environment like msys2 or cygwin? What is the output of your terminal?
I am using gcc ( mingw ). I even tried with clang but giving the same output
This is the output I am getting for gcc