1

I am trying to build legacy C program under Windows using mingw32 port. But gcc compiller informs me about next errors:

gmtime_r(const time_t*, struct tm*); //implicit declaration of function 
timegm(struct tm*); //implicit declaration of function 

I tried to declare _mkgmtime as suggested here but then I get the same error about declaration. I also tried to declare gmtime_r based on gmtime_s as descibed here but is seems that mingw does not support gmtime_s as well.

Is there any idea? Might need to replace them to some equivalents?

mingw-32 gcc 5.3.0-3 windows 7

Community
  • 1
  • 1
rvit34
  • 1,967
  • 3
  • 17
  • 33

1 Answers1

1

It's 2022 and the problem persists with GCC-10/MinGW64.

The solution is to define _POSIX_C_SOURCE which enables gmtime_r.

On command line:

x86_64-w64-mingw32-gcc -D_POSIX_C_SOURCE

autoconf/make:

CFLAGS=-D_POSIX_C_SOURCE

cmake:

add_compile_definitions(_POSIX_C_SOURCE)
mariusm
  • 1,483
  • 1
  • 11
  • 26