From 5299f8cdb67b9fae58de7fab049d114a5a98e5ae Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 19 Dec 2015 22:03:15 +0100 Subject: [PATCH] ngspice.h, cm.h, cleanup NAN defines --- src/include/ngspice/cm.h | 12 +++++------- src/include/ngspice/ngspice.h | 14 +++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/include/ngspice/cm.h b/src/include/ngspice/cm.h index 25db045ee..42681f37e 100644 --- a/src/include/ngspice/cm.h +++ b/src/include/ngspice/cm.h @@ -45,18 +45,16 @@ NON-STANDARD FEATURES #include "ngspice/cmproto.h" #include "ngspice/mifcmdat.h" -#if defined (_MSC_VER) -#ifndef NAN +#if !defined(NAN) +#if defined(_MSC_VER) && (_MSC_VER < 1800) + /* VS 2012 or less cannot evaluate 0.0/0.0 */ static const __int64 global_nan = 0x7ff8000000000000i64; #define NAN (*(const double *) &global_nan) +#else + #define NAN (0.0/0.0) #endif #endif -#if !defined(NAN) -#define NAN (0.0/0.0) -#endif - - /* * type safe variants of the functions for char arguments */ diff --git a/src/include/ngspice/ngspice.h b/src/include/ngspice/ngspice.h index 67c6b5211..2bd4fba73 100644 --- a/src/include/ngspice/ngspice.h +++ b/src/include/ngspice/ngspice.h @@ -195,11 +195,6 @@ extern double x_atanh(double); #define inline __inline #define popen _popen #define pclose _pclose -/* NAN not available in MS VS 2008 */ -#ifndef NAN - static const __int64 global_nan = 0x7ff8000000000000i64; - #define NAN (*(const double *) &global_nan) -#endif // undo a #define bool _Bool in MS Visual Studio 2015 #if defined(bool) @@ -210,9 +205,14 @@ extern double x_atanh(double); #pragma warning(disable: 4127) #endif -// for non C99 environments #if !defined(NAN) -#define NAN (0.0/0.0) +#if defined(_MSC_VER) && (_MSC_VER < 1800) + /* VS 2012 or less cannot evaluate 0.0/0.0 */ + static const __int64 global_nan = 0x7ff8000000000000i64; + #define NAN (*(const double *) &global_nan) +#else + #define NAN (0.0/0.0) +#endif #endif #if defined(__GNUC__)