Pārlūkot izejas kodu

Fix for thread safe rawtime on both GCC and MSVC

add-code-of-conduct-1
Trevor Irons 6 gadus atpakaļ
vecāks
revīzija
a296d0e51b
1 mainītis faili ar 10 papildinājumiem un 6 dzēšanām
  1. 10
    6
      Modules/LemmaCore/include/LemmaObject.h

+ 10
- 6
Modules/LemmaCore/include/LemmaObject.h Parādīt failu

@@ -89,14 +89,18 @@ class LemmaObject {
89 89
             //out << std::put_time(std::localtime(& now), L"%c") ; // locale on system
90 90
             // ISO-8601 format;
91 91
             //out << std::put_time(std::localtime(& now), "%F %T %z");
92
-            
93
-	    // Use thread safe variant to suppress MSVC warning
94
-	    struct tm timeinfo;
95
-	    localtime_s(&timeinfo, &now);
96
-	    // ISO-8601 format;
92
+
93
+            // Use thread safe variant to suppress MSVC warning
94
+            struct tm timeinfo;
95
+            #if _MSC_VER && !__INTEL_COMPILER
96
+            localtime_s(&timeinfo, &now);
97
+            #else
98
+            localtime_r(&now, &timeinfo);
99
+            #endif
100
+            // ISO-8601 format;
97 101
             out << std::put_time(&timeinfo, "%F %T %z");
98 102
 
99
-	    node["Serialized"] = out.str();
103
+	        node["Serialized"] = out.str();
100 104
             node["Lemma_VERSION"] = LEMMA_VERSION;
101 105
             return node;
102 106
         };

Notiek ielāde…
Atcelt
Saglabāt