[Spice-devel] [PATCH 18/20] mingw: workaround _ftime_s bug

Christophe Fergeau cfergeau at redhat.com
Thu Mar 1 02:17:52 PST 2012


mingw has a _ftime_s prototype in its headers, but no corresponding
symbol available at link time. Workaround this issue for now by
 #defining it to _ftime. This is untested on win64 where the workaround
may not be needed.
---
 common/vdlog.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/common/vdlog.h b/common/vdlog.h
index eebb0d2..b2a7295 100644
--- a/common/vdlog.h
+++ b/common/vdlog.h
@@ -57,13 +57,19 @@ static unsigned int log_level = LOG_INFO;
     printf("%lu::%s::%s,%.3d::%s::" format "\n", GetCurrentThreadId(), type, datetime, ms,       \
            __FUNCTION__, ## __VA_ARGS__);
 
+#ifdef __MINGW32__
+#define vd_ftime_s _ftime
+#else
+#define vd_ftime_s _ftime_s
+#endif
+
 #define LOG(type, format, ...) if (type >= log_level && type <= LOG_FATAL) {                    \
     VDLog* log = VDLog::get();                                                                  \
     const char *type_as_char[] = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL" };                 \
     struct _timeb now;                                                                          \
     struct tm today;                                                                            \
     char datetime_str[20];                                                                      \
-    _ftime_s(&now);                                                                             \
+    vd_ftime_s(&now);                                                                             \
     localtime_s(&today, &now.time);                                                             \
     strftime(datetime_str, 20, "%Y-%m-%d %H:%M:%S", &today);                                    \
     if (log) {                                                                                  \
-- 
1.7.7.6



More information about the Spice-devel mailing list