htmldoc icon indicating copy to clipboard operation
htmldoc copied to clipboard

gmtime_r/localtime_r on MinGW-w64

Open brechtsanders opened this issue 3 years ago • 2 comments

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.

brechtsanders avatar May 20 '22 12:05 brechtsanders

@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.

michaelrsweet avatar May 23 '22 12:05 michaelrsweet

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).

brechtsanders avatar May 23 '22 13:05 brechtsanders

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

michaelrsweet avatar Dec 10 '22 01:12 michaelrsweet

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

brechtsanders avatar Dec 10 '22 07:12 brechtsanders