From ac25ba0a3f1ffb797e91e335654e91b8778aff4a Mon Sep 17 00:00:00 2001 From: Photonios Date: Tue, 22 Sep 2015 18:25:53 +0200 Subject: [PATCH 1/2] Fix for MSVC 2015: isnan is supported in this version --- psycopg/config.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/psycopg/config.h b/psycopg/config.h index b6cd4190..255fc3a7 100644 --- a/psycopg/config.h +++ b/psycopg/config.h @@ -129,14 +129,15 @@ static int pthread_mutex_init(pthread_mutex_t *mutex, void* fake) /* remove the inline keyword, since it doesn't work unless C++ file */ #define inline -/* Hmmm, MSVC doesn't have a isnan/isinf function, but has _isnan function */ +/* Hmmm, MSVC <2015 doesn't have a isnan/isinf function, but has _isnan function */ #if defined (_MSC_VER) +#if !defined(isnan) #define isnan(x) (_isnan(x)) /* The following line was hacked together from simliar code by Bjorn Reese * in libxml2 code */ #define isinf(x) ((_fpclass(x) == _FPCLASS_PINF) ? 1 \ : ((_fpclass(x) == _FPCLASS_NINF) ? -1 : 0)) - +#endif #define strcasecmp(x, y) lstrcmpi(x, y) #endif #endif From 71925fcc00a3e41c255c244e124b58144cecb6a1 Mon Sep 17 00:00:00 2001 From: Photonios Date: Tue, 22 Sep 2015 18:26:14 +0200 Subject: [PATCH 2/2] Fix for MSVC 2015: round has been added to this version --- psycopg/config.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/psycopg/config.h b/psycopg/config.h index 255fc3a7..f8e17a9a 100644 --- a/psycopg/config.h +++ b/psycopg/config.h @@ -142,16 +142,20 @@ static int pthread_mutex_init(pthread_mutex_t *mutex, void* fake) #endif #endif +/* what's this, we have no round function either? */ #if (defined(__FreeBSD__) && __FreeBSD_version < 503000) \ || (defined(_WIN32) && !defined(__GNUC__)) \ || (defined(sun) || defined(__sun__)) \ && (defined(__SunOS_5_8) || defined(__SunOS_5_9)) -/* what's this, we have no round function either? */ + +/* round has been added in the standard library with MSVC 2015 */ +#if _MSC_VER < 1900 static double round(double num) { return (num >= 0) ? floor(num + 0.5) : ceil(num - 0.5); } #endif +#endif /* resolve missing isinf() function for Solaris */ #if defined (__SVR4) && defined (__sun)