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
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.