Просмотр исходного кода

Fixed conflicts with `isnan()` and `isinf()` macros (fixes #752)

Benoit Blanchon 7 лет назад
Родитель
Сommit
c3403ed72d
4 измененных файлов с 21 добавлено и 4 удалено
  1. 1 1
      .travis.yml
  2. 5 0
      CHANGELOG.md
  3. 7 3
      scripts/travis/arduino.sh
  4. 8 0
      src/ArduinoJson/Polyfills/math.hpp

+ 1 - 1
.travis.yml

@@ -105,7 +105,7 @@ matrix:
       compiler: clang
       env: SCRIPT=cmake SANITIZE=address
     - env: SCRIPT=arduino VERSION=1.6.7 BOARD=arduino:avr:uno
-    - env: SCRIPT=arduino VERSION=1.8.2 BOARD=arduino:avr:uno
+    - env: SCRIPT=arduino VERSION=1.8.2 BOARD=arduino:samd:mkr1000
     - env: SCRIPT=platformio BOARD=uno
     - env: SCRIPT=platformio BOARD=esp01
     - compiler: clang

+ 5 - 0
CHANGELOG.md

@@ -1,6 +1,11 @@
 ArduinoJson: change log
 =======================
 
+HEAD
+----
+
+* Fixed conflicts with `isnan()` and `isinf()` macros (issue #752)
+
 v6.0.0-beta
 -----------
 

+ 7 - 3
scripts/travis/arduino.sh

@@ -1,4 +1,4 @@
-#!/bin/sh -eux
+#!/bin/bash -eux
 
 /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
 sleep 3
@@ -6,9 +6,13 @@ export DISPLAY=:1.0
 
 mkdir -p /tmp/arduino
 curl -sS http://downloads.arduino.cc/arduino-$VERSION-linux64.tar.xz | tar xJ -C /tmp/arduino --strip 1 ||
-curl -sS http://downloads.arduino.cc/arduino-$VERSION-linux64.tgz | tar xz -C /tmp/arduino --strip 1 
+curl -sS http://downloads.arduino.cc/arduino-$VERSION-linux64.tgz | tar xz -C /tmp/arduino --strip 1
 export PATH=$PATH:/tmp/arduino/
-  
+
+if [[ "$BOARD" =~ "arduino:samd:" ]]; then
+  arduino --install-boards arduino:samd
+fi
+
 ln -s $PWD /tmp/arduino/libraries/ArduinoJson
 
 for EXAMPLE in $PWD/examples/*/*.ino; do

+ 8 - 0
src/ArduinoJson/Polyfills/math.hpp

@@ -6,14 +6,22 @@
 
 namespace ArduinoJson {
 namespace Internals {
+
+// Some libraries #define isnan() and isinf() so we need to check before
+// using this name
+
+#ifndef isnan
 template <typename T>
 bool isnan(T x) {
   return x != x;
 }
+#endif
 
+#ifndef isinf
 template <typename T>
 bool isinf(T x) {
   return x != 0.0 && x * 2 == x;
 }
+#endif
 }  // namespace Internals
 }  // namespace ArduinoJson