Pārlūkot izejas kodu

Added an clear message for `StaticJsonDocument`, `DynamicJsonDocument`...

Benoit Blanchon 7 gadi atpakaļ
vecāks
revīzija
f20f8e3171
3 mainītis faili ar 34 papildinājumiem un 0 dzēšanām
  1. 1 0
      CHANGELOG.md
  2. 2 0
      src/ArduinoJson.hpp
  3. 31 0
      src/ArduinoJson/compatibility.hpp

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ HEAD
 
 * Fixed warning "unused variable" with GCC 4.4 (issue #912)
 * Fixed warning "maybe uninitialized" (issue #909)
+* Added an clear message for `StaticJsonDocument`, `DynamicJsonDocument`...
 
 v5.13.4
 -------

+ 2 - 0
src/ArduinoJson.hpp

@@ -17,3 +17,5 @@
 #include "ArduinoJson/JsonObjectImpl.hpp"
 #include "ArduinoJson/JsonVariantImpl.hpp"
 #include "ArduinoJson/Serialization/JsonSerializerImpl.hpp"
+
+#include "ArduinoJson/compatibility.hpp"

+ 31 - 0
src/ArduinoJson/compatibility.hpp

@@ -0,0 +1,31 @@
+// ArduinoJson - arduinojson.org
+// Copyright Benoit Blanchon 2014-2019
+// MIT License
+//
+// clang-format off
+
+#ifdef __GNUC__
+
+#define ARDUINOJSON_PRAGMA(x) _Pragma(#x)
+
+#define ARDUINOJSON_COMPILE_ERROR(msg) ARDUINOJSON_PRAGMA(GCC error msg)
+
+#define ARDUINOJSON_STRINGIFY(S) #S
+
+#define ARDUINOJSON_DEPRECATION_ERROR(X, Y) \
+  ARDUINOJSON_COMPILE_ERROR(ARDUINOJSON_STRINGIFY(X is a Y from ArduinoJson 6 but version 5 is installed. Visit arduinojson.org to get more information.))
+
+#define StaticJsonDocument ARDUINOJSON_DEPRECATION_ERROR(StaticJsonDocument, class)
+#define DynamicJsonDocument ARDUINOJSON_DEPRECATION_ERROR(DynamicJsonDocument, class)
+#define JsonDocument ARDUINOJSON_DEPRECATION_ERROR(JsonDocument, class)
+#define DeserializationError ARDUINOJSON_DEPRECATION_ERROR(DeserializationError, class)
+#define deserializeJson ARDUINOJSON_DEPRECATION_ERROR(deserializeJson, function)
+#define deserializeMsgPack ARDUINOJSON_DEPRECATION_ERROR(deserializeMsgPack, function)
+#define serializeJson ARDUINOJSON_DEPRECATION_ERROR(serializeJson, function)
+#define serializeMsgPack ARDUINOJSON_DEPRECATION_ERROR(serializeMsgPack, function)
+#define serializeJsonPretty ARDUINOJSON_DEPRECATION_ERROR(serializeJsonPretty, function)
+#define measureMsgPack ARDUINOJSON_DEPRECATION_ERROR(measureMsgPack, function)
+#define measureJson ARDUINOJSON_DEPRECATION_ERROR(measureJson, function)
+#define measureJsonPretty ARDUINOJSON_DEPRECATION_ERROR(measureJsonPretty, function)
+
+#endif