From f8d41c2eec776ce3c9920fd01fd3971dc99cf531 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 22 Apr 2007 15:45:05 +0000 Subject: Compile fix for Win32, where no localtime_r is available and localtime is thread safe. (refs #3) --- lib/common/Logging.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp index 4078a679..bb728183 100644 --- a/lib/common/Logging.cpp +++ b/lib/common/Logging.cpp @@ -210,7 +210,7 @@ bool Console::Log(Log::Level level, const std::string& rFile, if (sShowTime) { - struct tm time_now; + struct tm time_now, *tm_ptr = &time_now; time_t time_t_now = time(NULL); if (time_t_now == ((time_t)-1)) @@ -218,13 +218,17 @@ bool Console::Log(Log::Level level, const std::string& rFile, msg += strerror(errno); msg += " "; } - else if (localtime_r(&time_t_now, &time_now) != NULL) + #ifdef WIN32 + else if ((tm_ptr = localtime(&time_t_now)) != NULL) + #else + else if (localtime_r(&time_t_now, &time_now) != NULL) + #endif { std::ostringstream buf; buf << std::setfill('0') << - std::setw(2) << time_now.tm_hour << ":" << - std::setw(2) << time_now.tm_min << ":" << - std::setw(2) << time_now.tm_sec << " "; + std::setw(2) << tm_ptr->tm_hour << ":" << + std::setw(2) << tm_ptr->tm_min << ":" << + std::setw(2) << tm_ptr->tm_sec << " "; msg += buf.str(); } else -- cgit v1.2.3