]> git.ipfire.org Git - thirdparty/git.git/commitdiff
win32: ensure that `localtime_r()` is declared even in i686 builds
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 22 Jun 2026 08:44:06 +0000 (08:44 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Jun 2026 13:00:30 +0000 (06:00 -0700)
The `__MINGW64__` constant is defined, surprise, surprise, only when
building for a 64-bit CPU architecture.

Therefore using it as a guard to define `_POSIX_C_SOURCE` (so that
`localtime_r()` is declared, among other functions) is not enough, we
also need to check `__MINGW32__`.

Technically, the latter constant is defined even for 64-bit builds. But
let's make things a bit easier to understand by testing for both
constants.

Making it so fixes this compile warning (turned error in GCC v14.1):

  archive-zip.c: In function 'dos_time':
  archive-zip.c:612:9: error: implicit declaration of function 'localtime_r';
  did you mean 'localtime_s'? [-Wimplicit-function-declaration]
    612 |         localtime_r(&time, &tm);
        |         ^~~~~~~~~~~
        |         localtime_s

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/posix.h

index 2f01564b0d8a601b3ae0e3c44e334b09102d6397..e2e794cad7d41980ad55333a4a1e62034cd9bca8 100644 (file)
@@ -56,7 +56,7 @@
 # define UNUSED
 #endif
 
-#ifdef __MINGW64__
+#if defined(__MINGW32__) || defined(__MINGW64__)
 #define _POSIX_C_SOURCE 1
 #elif defined(__sun__)
  /*