From c7d6d33e6c91bb51ff1ba1ed74392890f8134d16 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Mon, 6 Jun 2016 22:10:28 +0200 Subject: [PATCH] Fixed compilation error with Intel Galileo (issue #299) --- CHANGELOG.md | 5 +++ include/ArduinoJson/JsonBuffer.hpp | 14 ++++++++- include/ArduinoJson/Polyfills/isInfinity.hpp | 22 +++++++++++++- include/ArduinoJson/Polyfills/isNaN.hpp | 32 ++++++++++++-------- 4 files changed, 59 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54dff7fe..a74b64d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ ArduinoJson: change log ======================= +HEAD +---- + +* Fixed compilation error with Intel Galileo (issue #299) + v5.5.0 ------ diff --git a/include/ArduinoJson/JsonBuffer.hpp b/include/ArduinoJson/JsonBuffer.hpp index 128a3511..aae5f21e 100644 --- a/include/ArduinoJson/JsonBuffer.hpp +++ b/include/ArduinoJson/JsonBuffer.hpp @@ -11,12 +11,16 @@ #include // for uint8_t #include -#include "String.hpp" #include "JsonVariant.hpp" +#include "String.hpp" #if defined(__clang__) +#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif defined(__GNUC__) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#pragma GCC diagnostic push +#endif #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif @@ -149,3 +153,11 @@ class JsonBuffer { static const uint8_t DEFAULT_LIMIT = 10; }; } + +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(__GNUC__) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#pragma GCC diagnostic pop +#endif +#endif diff --git a/include/ArduinoJson/Polyfills/isInfinity.hpp b/include/ArduinoJson/Polyfills/isInfinity.hpp index b3b3b5a3..be1f9fa8 100644 --- a/include/ArduinoJson/Polyfills/isInfinity.hpp +++ b/include/ArduinoJson/Polyfills/isInfinity.hpp @@ -14,6 +14,18 @@ #include #endif +// GCC warning: "conversion to 'float' from 'double' may alter its value" +#ifdef __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#pragma GCC diagnostic push +#endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) +#pragma GCC diagnostic ignored "-Wfloat-conversion" +#else +#pragma GCC diagnostic ignored "-Wconversion" +#endif +#endif + namespace ArduinoJson { namespace Polyfills { @@ -29,12 +41,14 @@ bool isInfinity(T x) { return isinf(x); } -#ifdef __GLIBC__ +#if defined(_GLIBCXX_HAVE_ISINFL) && _GLIBCXX_HAVE_ISINFL template <> inline bool isInfinity(double x) { return isinfl(x); } +#endif +#if defined(_GLIBCXX_HAVE_ISINFF) && _GLIBCXX_HAVE_ISINFF template <> inline bool isInfinity(float x) { return isinff(x); @@ -43,3 +57,9 @@ inline bool isInfinity(float x) { #endif } } + +#if defined(__GNUC__) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#pragma GCC diagnostic pop +#endif +#endif diff --git a/include/ArduinoJson/Polyfills/isNaN.hpp b/include/ArduinoJson/Polyfills/isNaN.hpp index 0fb72577..cc378143 100644 --- a/include/ArduinoJson/Polyfills/isNaN.hpp +++ b/include/ArduinoJson/Polyfills/isNaN.hpp @@ -14,33 +14,41 @@ #include #endif +// GCC warning: "conversion to 'float' from 'double' may alter its value" +#ifdef __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#pragma GCC diagnostic push +#endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) +#pragma GCC diagnostic ignored "-Wfloat-conversion" +#else +#pragma GCC diagnostic ignored "-Wconversion" +#endif +#endif + namespace ArduinoJson { namespace Polyfills { // If Visual Studo <= 2012 #if defined(_MSC_VER) && _MSC_VER <= 1700 + template bool isNaN(T x) { return _isnan(x) != 0; } #else + template bool isNaN(T x) { return isnan(x); } -#ifdef __GLIBC__ -template <> -inline bool isNaN(double x) { - return isnanl(x); -} - -template <> -inline bool isNaN(float x) { - return isnanf(x); -} -#endif - #endif } } + +#if defined(__GNUC__) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#pragma GCC diagnostic pop +#endif +#endif