Skip to content

Commit

Permalink
win32: ensure that localtime_r() is declared even in i686 builds
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dscho committed Jun 3, 2024
1 parent a1dc740 commit a74a04f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct strbuf;
/* Approximation of the length of the decimal representation of this type. */
#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)

#ifdef __MINGW64__
#if defined(__MINGW32__) || defined(__MINGW64__)
#define _POSIX_C_SOURCE 1
#elif defined(__sun__)
/*
Expand Down

0 comments on commit a74a04f

Please sign in to comment.