Something has changed in the mingw-w64 headers such that we no-longer compile when using 7.0.0.
0util/time.cpp: In function 'std::__cxx11::string FormatISO8601DateTime(int64_t)':
1util/time.cpp:84:9: error: 'gmtime_r' was not declared in this scope
2 if (gmtime_r(&time_val, &ts) == nullptr) {
3 ^~~~~~~~
4util/time.cpp: In function 'std::__cxx11::string FormatISO8601Date(int64_t)':
5util/time.cpp:97:9: error: 'gmtime_r' was not declared in this scope
6 if (gmtime_r(&time_val, &ts) == nullptr) {
Looking at time.h, it seems that gmtime_r()
is only available when
_POSIX_C_SOURCE
is defined. This must have been the case for 6.0.0
(which we compile fine using), but no-longer seems to be for 7.0.0?
I’ve checked that adding -D_POSIX_C_SOURCE=200112L
to our compile
flags does fix the issue above.
However, an alternative solution seems to be to just use gmtime_s()
instead, when compiling with mingw-w64
, as gmtime_r()
just wraps
gmtime_s()
anyways.
I’ve tested this change crosss-compiling on Debian Bullseye (mingw-w64 7.0.0) and Buster (mingw-w64 6.0.0).