Fix MinGW stat redefinition and thread-safe localtime

- Guard #define stat _stat with !defined(__MINGW32__) to avoid conflicts with MinGW's own POSIX-compliant stat implementation

- Replace _MSC_VER check with defined(_WIN32) for localtime_s to allow all Windows compilers including MinGW to use the secure function

Fixes #3038, #3037
This commit is contained in:
ashutosh0x
2026-02-11 22:32:21 +05:30
parent cc5d544d15
commit 2ab76ec4f5
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ void mju_writeLog(const char* type, const char* msg) {
#if defined(_POSIX_C_SOURCE) || defined(__APPLE__) || defined(__STDC_VERSION_TIME_H__) || defined(__EMSCRIPTEN__)
localtime_r(&rawtime, &timeinfo);
#elif _MSC_VER
#elif defined(_WIN32)
localtime_s(&timeinfo, &rawtime);
#elif __STDC_LIB_EXT1__
localtime_s(&rawtime, &timeinfo);
+1 -1
View File
@@ -15,7 +15,7 @@
#include "user/user_vfs.h"
#include <sys/stat.h>
#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#define stat _stat
#endif