Skip to content

Commit ab23625

Browse files
committed
Renamed DEPRECATED to ARDUINOJSON_DEPRECATED
1 parent a88cf8f commit ab23625

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

extras/tests/Misc/deprecated.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22
// Copyright Benoit Blanchon 2014-2021
33
// MIT License
44

5+
#define ARDUINOJSON_DEPRECATED(msg) // nothing
6+
57
#include <ArduinoJson.h>
68
#include <catch.hpp>
79

8-
#if defined(__GNUC__)
9-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
10-
#endif
11-
12-
#ifdef _MSC_VER
13-
#pragma warning(disable : 4996) // deprecation warning
14-
#endif
15-
1610
TEST_CASE("Deprecated features") {
1711
StaticJsonDocument<256> doc;
1812
const char* s = "hello";

src/ArduinoJson/Array/ElementProxy.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >,
7272

7373
template <typename T>
7474
FORCE_INLINE typename enable_if<is_same<T, char*>::value, const char*>::type
75-
DEPRECATED("Replace as<char*>() with as<const char*>()") as() const {
75+
ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()")
76+
as() const {
7677
return as<const char*>();
7778
}
7879

src/ArduinoJson/Object/MemberProxy.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >,
7575

7676
template <typename T>
7777
FORCE_INLINE typename enable_if<is_same<T, char *>::value, const char *>::type
78-
DEPRECATED("Replace as<char*>() with as<const char*>()") as() const {
78+
ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()")
79+
as() const {
7980
return as<const char *>();
8081
}
8182

src/ArduinoJson/Polyfills/attributes.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,32 @@
88

99
#define FORCE_INLINE // __forceinline causes C4714 when returning std::string
1010
#define NO_INLINE __declspec(noinline)
11-
#define DEPRECATED(msg) __declspec(deprecated(msg))
11+
12+
#ifndef ARDUINOJSON_DEPRECATED
13+
#define ARDUINOJSON_DEPRECATED(msg) __declspec(deprecated(msg))
14+
#endif
1215

1316
#elif defined(__GNUC__) // GCC or Clang
1417

1518
#define FORCE_INLINE __attribute__((always_inline))
1619
#define NO_INLINE __attribute__((noinline))
20+
21+
#ifndef ARDUINOJSON_DEPRECATED
1722
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
18-
#define DEPRECATED(msg) __attribute__((deprecated(msg)))
23+
#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated(msg)))
1924
#else
20-
#define DEPRECATED(msg) __attribute__((deprecated))
25+
#define ARDUINOJSON_DEPRECATED(msg) __attribute__((deprecated))
26+
#endif
2127
#endif
2228

2329
#else // Other compilers
2430

2531
#define FORCE_INLINE
2632
#define NO_INLINE
27-
#define DEPRECATED(msg)
33+
34+
#ifndef ARDUINOJSON_DEPRECATED
35+
#define ARDUINOJSON_DEPRECATED(msg)
36+
#endif
2837

2938
#endif
3039

src/ArduinoJson/Variant/VariantRef.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class VariantRef : public VariantRefBase<VariantData>,
101101

102102
template <typename T>
103103
FORCE_INLINE typename enable_if<is_same<T, char *>::value, const char *>::type
104-
DEPRECATED("Replace as<char*>() with as<const char*>()") as() const {
104+
ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()")
105+
as() const {
105106
return as<const char *>();
106107
}
107108

@@ -218,7 +219,8 @@ class VariantConstRef : public VariantRefBase<const VariantData>,
218219

219220
template <typename T>
220221
FORCE_INLINE typename enable_if<is_same<T, char *>::value, const char *>::type
221-
DEPRECATED("Replace as<char*>() with as<const char*>()") as() const {
222+
ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()")
223+
as() const {
222224
return as<const char *>();
223225
}
224226

0 commit comments

Comments
 (0)