asn1c icon indicating copy to clipboard operation
asn1c copied to clipboard

Compiling GeneralizedTime.c fails on WSL/Ubuntu

Open gaetanww opened this issue 6 years ago • 8 comments

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,

gaetanww avatar Oct 15 '19 10:10 gaetanww

Manually including </usr/include/time.h> in GeneralizedTime.c and UTCTime.c solved the issue as a workaround.

gaetanww avatar Oct 16 '19 14:10 gaetanww

I am facing the same issue on windows. Do you know any workaround?

chetanpandey1266 avatar Sep 29 '23 06:09 chetanpandey1266

Manually including </usr/include/time.h> in GeneralizedTime.c and UTCTime.c solved the issue as a workaround.

That didn't work?

gaetanww avatar Sep 29 '23 08:09 gaetanww

No it is giving no such file or directory

chetanpandey1266 avatar Sep 29 '23 10:09 chetanpandey1266

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??

chetanpandey1266 avatar Sep 29 '23 10:09 chetanpandey1266

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?

kentkost avatar Sep 29 '23 10:09 kentkost

I am using gcc ( mingw ). I even tried with clang but giving the same output

chetanpandey1266 avatar Sep 29 '23 10:09 chetanpandey1266

This is the output I am getting for gcc image

chetanpandey1266 avatar Sep 29 '23 10:09 chetanpandey1266