michaelrsweet / htmldoc

HTML Conversion Software
https://www.msweet.org/htmldoc
GNU General Public License v2.0
206 stars 46 forks source link

gmtime_r/localtime_r on MinGW-w64 #489

Closed brechtsanders closed 1 year ago

brechtsanders commented 2 years ago

When building for Windows with recent MinGW-w64 (e.g. GCC12 from https://winlibs.com/) gmtime_r and localtime_r are actually available if _POSIX_THREAD_SAFE_FUNCTIONS is defined.

There is some code that addresses previously missing functions in MinGW, like define localtime_r(t,tm) localtime_s(tm,t) in htmldoc/zipc.c, but it would be better to guard this code with #ifndef _POSIX_THREAD_SAFE_FUNCTIONS.

Maybe configure can also be fixed to detect if gmtime_r and localtime_r are available in MinGW-w64 of _POSIX_THREAD_SAFE_FUNCTIONS is defined.

michaelrsweet commented 2 years ago

@brechtsanders Even in MinGW, the Windows API functions are still available, right? I really don't want to special-case this as MinGW isn't a platform/toolset I support or use.

brechtsanders commented 2 years ago

MinGW provides Windows API functions, and additionally a subset of POSIX (e.g. pthreads). The fact that you already treat gmtime_r and localtime_r differently for Windows is sort of the issue, as recent MinGW-w64 (not sure about old MinGW) also define these (when _POSIX_THREAD_SAFE_FUNCTIONS is defined).

michaelrsweet commented 1 year ago

Sorry, I'm not going to special-case MingW support for HTMLDOC.

brechtsanders commented 1 year ago

The issue still exists in 5.5.3, but when building current master for win64 it succeeds.