Selaa lähdekoodia

Fix for thread safe rawtime on both GCC and MSVC

add-code-of-conduct-1
Trevor Irons 5 vuotta sitten
vanhempi
commit
a296d0e51b
1 muutettua tiedostoa jossa 10 lisäystä ja 6 poistoa
  1. 10
    6
      Modules/LemmaCore/include/LemmaObject.h

+ 10
- 6
Modules/LemmaCore/include/LemmaObject.h Näytä tiedosto

89
             //out << std::put_time(std::localtime(& now), L"%c") ; // locale on system
89
             //out << std::put_time(std::localtime(& now), L"%c") ; // locale on system
90
             // ISO-8601 format;
90
             // ISO-8601 format;
91
             //out << std::put_time(std::localtime(& now), "%F %T %z");
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
             out << std::put_time(&timeinfo, "%F %T %z");
101
             out << std::put_time(&timeinfo, "%F %T %z");
98
 
102
 
99
-	    node["Serialized"] = out.str();
103
+	        node["Serialized"] = out.str();
100
             node["Lemma_VERSION"] = LEMMA_VERSION;
104
             node["Lemma_VERSION"] = LEMMA_VERSION;
101
             return node;
105
             return node;
102
         };
106
         };

Loading…
Peruuta
Tallenna