[glib/266.c89] gdatetime.c: Fix MSVC builds for lack of NAN items




commit ee70cba312b618a61e5b015f2c1fa0d2394d2f60
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Dec 30 18:46:33 2020 +0800

    gdatetime.c: Fix MSVC builds for lack of NAN items
    
    Use a fallback for isnan() on Visual Studio 2012 or earlier, and define
    NAN if it does not exist.

 glib/gdatetime.c       | 4 ++++
 glib/tests/gdatetime.c | 4 ++++
 2 files changed, 8 insertions(+)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 02cc3bd01..00dc6152f 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -80,6 +80,10 @@
 #ifndef G_OS_WIN32
 #include <sys/time.h>
 #include <time.h>
+#else
+#if (_MSC_VER < 1800)
+#define isnan _isnan
+#endif
 #endif /* !G_OS_WIN32 */
 
 /**
diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
index 0203dd0c2..3b1d9cf7d 100644
--- a/glib/tests/gdatetime.c
+++ b/glib/tests/gdatetime.c
@@ -29,6 +29,10 @@
 #ifdef G_OS_WIN32
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
+
+#ifndef NAN
+#define NAN HUGE_VAL * 0.0f
+#endif
 #endif
 
 #define ASSERT_DATE(dt,y,m,d) G_STMT_START { \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]