From ab23625091a56d7635a4e06562cce4def2bb2464 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 4 May 2021 14:35:14 +0200 Subject: [PATCH] Renamed DEPRECATED to ARDUINOJSON_DEPRECATED --- extras/tests/Misc/deprecated.cpp | 10 ++-------- src/ArduinoJson/Array/ElementProxy.hpp | 3 ++- src/ArduinoJson/Object/MemberProxy.hpp | 3 ++- src/ArduinoJson/Polyfills/attributes.hpp | 17 +++++++++++++---- src/ArduinoJson/Variant/VariantRef.hpp | 6 ++++-- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/extras/tests/Misc/deprecated.cpp b/extras/tests/Misc/deprecated.cpp index a8a92dec..1d1eb422 100644 --- a/extras/tests/Misc/deprecated.cpp +++ b/extras/tests/Misc/deprecated.cpp @@ -2,17 +2,11 @@ // Copyright Benoit Blanchon 2014-2021 // MIT License +#define ARDUINOJSON_DEPRECATED(msg) // nothing + #include #include -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - -#ifdef _MSC_VER -#pragma warning(disable : 4996) // deprecation warning -#endif - TEST_CASE("Deprecated features") { StaticJsonDocument<256> doc; const char* s = "hello"; diff --git a/src/ArduinoJson/Array/ElementProxy.hpp b/src/ArduinoJson/Array/ElementProxy.hpp index 346d3ba7..c6062e49 100644 --- a/src/ArduinoJson/Array/ElementProxy.hpp +++ b/src/ArduinoJson/Array/ElementProxy.hpp @@ -72,7 +72,8 @@ class ElementProxy : public VariantOperators >, template FORCE_INLINE typename enable_if::value, const char*>::type - DEPRECATED("Replace as() with as()") as() const { + ARDUINOJSON_DEPRECATED("Replace as() with as()") + as() const { return as(); } diff --git a/src/ArduinoJson/Object/MemberProxy.hpp b/src/ArduinoJson/Object/MemberProxy.hpp index a3cb6e8d..0bee84bf 100644 --- a/src/ArduinoJson/Object/MemberProxy.hpp +++ b/src/ArduinoJson/Object/MemberProxy.hpp @@ -75,7 +75,8 @@ class MemberProxy : public VariantOperators >, template FORCE_INLINE typename enable_if::value, const char *>::type - DEPRECATED("Replace as() with as()") as() const { + ARDUINOJSON_DEPRECATED("Replace as() with as()") + as() const { return as(); } diff --git a/src/ArduinoJson/Polyfills/attributes.hpp b/src/ArduinoJson/Polyfills/attributes.hpp index 7ebd3bc1..f04c9acc 100644 --- a/src/ArduinoJson/Polyfills/attributes.hpp +++ b/src/ArduinoJson/Polyfills/attributes.hpp @@ -8,23 +8,32 @@ #define FORCE_INLINE // __forceinline causes C4714 when returning std::string #define NO_INLINE __declspec(noinline) -#define DEPRECATED(msg) __declspec(deprecated(msg)) + +#ifndef ARDUINOJSON_DEPRECATED +#define ARDUINOJSON_DEPRECATED(msg) __declspec(deprecated(msg)) +#endif #elif defined(__GNUC__) // GCC or Clang #define FORCE_INLINE __attribute__((always_inline)) #define NO_INLINE __attribute__((noinline)) + +#ifndef ARDUINOJSON_DEPRECATED #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -#define DEPRECATED(msg) __attribute__((deprecated(msg))) +#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated(msg))) #else -#define DEPRECATED(msg) __attribute__((deprecated)) +#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated)) +#endif #endif #else // Other compilers #define FORCE_INLINE #define NO_INLINE -#define DEPRECATED(msg) + +#ifndef ARDUINOJSON_DEPRECATED +#define ARDUINOJSON_DEPRECATED(msg) +#endif #endif diff --git a/src/ArduinoJson/Variant/VariantRef.hpp b/src/ArduinoJson/Variant/VariantRef.hpp index 3b9e359c..65913ae7 100644 --- a/src/ArduinoJson/Variant/VariantRef.hpp +++ b/src/ArduinoJson/Variant/VariantRef.hpp @@ -101,7 +101,8 @@ class VariantRef : public VariantRefBase, template FORCE_INLINE typename enable_if::value, const char *>::type - DEPRECATED("Replace as() with as()") as() const { + ARDUINOJSON_DEPRECATED("Replace as() with as()") + as() const { return as(); } @@ -218,7 +219,8 @@ class VariantConstRef : public VariantRefBase, template FORCE_INLINE typename enable_if::value, const char *>::type - DEPRECATED("Replace as() with as()") as() const { + ARDUINOJSON_DEPRECATED("Replace as() with as()") + as() const { return as(); }