Fixed compilation error with Intel Galileo (issue #299)

This commit is contained in:
Benoit Blanchon
2016-06-06 22:10:28 +02:00
parent c705f3cfeb
commit c7d6d33e6c
4 changed files with 59 additions and 14 deletions

View File

@ -1,6 +1,11 @@
ArduinoJson: change log ArduinoJson: change log
======================= =======================
HEAD
----
* Fixed compilation error with Intel Galileo (issue #299)
v5.5.0 v5.5.0
------ ------

View File

@ -11,12 +11,16 @@
#include <stdint.h> // for uint8_t #include <stdint.h> // for uint8_t
#include <string.h> #include <string.h>
#include "String.hpp"
#include "JsonVariant.hpp" #include "JsonVariant.hpp"
#include "String.hpp"
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnon-virtual-dtor" #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
#elif defined(__GNUC__) #elif defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif #endif
@ -149,3 +153,11 @@ class JsonBuffer {
static const uint8_t DEFAULT_LIMIT = 10; 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

View File

@ -14,6 +14,18 @@
#include <math.h> #include <math.h>
#endif #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 ArduinoJson {
namespace Polyfills { namespace Polyfills {
@ -29,12 +41,14 @@ bool isInfinity(T x) {
return isinf(x); return isinf(x);
} }
#ifdef __GLIBC__ #if defined(_GLIBCXX_HAVE_ISINFL) && _GLIBCXX_HAVE_ISINFL
template <> template <>
inline bool isInfinity<double>(double x) { inline bool isInfinity<double>(double x) {
return isinfl(x); return isinfl(x);
} }
#endif
#if defined(_GLIBCXX_HAVE_ISINFF) && _GLIBCXX_HAVE_ISINFF
template <> template <>
inline bool isInfinity<float>(float x) { inline bool isInfinity<float>(float x) {
return isinff(x); return isinff(x);
@ -43,3 +57,9 @@ inline bool isInfinity<float>(float x) {
#endif #endif
} }
} }
#if defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif
#endif

View File

@ -14,33 +14,41 @@
#include <math.h> #include <math.h>
#endif #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 ArduinoJson {
namespace Polyfills { namespace Polyfills {
// If Visual Studo <= 2012 // If Visual Studo <= 2012
#if defined(_MSC_VER) && _MSC_VER <= 1700 #if defined(_MSC_VER) && _MSC_VER <= 1700
template <typename T> template <typename T>
bool isNaN(T x) { bool isNaN(T x) {
return _isnan(x) != 0; return _isnan(x) != 0;
} }
#else #else
template <typename T> template <typename T>
bool isNaN(T x) { bool isNaN(T x) {
return isnan(x); return isnan(x);
} }
#ifdef __GLIBC__
template <>
inline bool isNaN<double>(double x) {
return isnanl(x);
}
template <>
inline bool isNaN<float>(float x) {
return isnanf(x);
}
#endif
#endif #endif
} }
} }
#if defined(__GNUC__)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC diagnostic pop
#endif
#endif