Browse Source

Fix a 64bit function that was also being called when the environment is 32btis.

The function _localtime64 was being called inside a ifdef WIN32 which
makes it try to compile even when it's in a 32bti environment.
Now if it calls _localtime32 in that case.
Tested on Windows using Msys+mingw 32bit shell.

Signed-off-by: Samega 7Cattac <7Cattac@gmail.com>
Samega 7Cattac 3 years ago
parent
commit
e43af7c06e
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/oatpp/core/base/Environment.cpp

+ 8 - 1
src/oatpp/core/base/Environment.cpp

@@ -33,12 +33,19 @@
 #include <cstdarg>
 
 #if defined(WIN32) || defined(_WIN32)
-#include <WinSock2.h>
+	#include <WinSock2.h>
+#endif
 
+#if (defined(WIN32) || defined(_WIN32)) && defined(_WIN64)
 struct tm* localtime_r(time_t *_clock, struct tm *_result) {
     _localtime64_s(_result, _clock);
     return _result;
 }
+#elif (defined(WIN32) || defined(_WIN32)) && not defined(_WIN64)
+struct tm* localtime_r(time_t *_clock, struct tm *_result) {
+    _localtime32_s(_result, _clock);
+    return _result;
+}
 #endif
 
 namespace oatpp { namespace base {