Skip to content

Commit b27c83f

Browse files
dota17baylesj
authored andcommitted
Delete JSONCPP_DEPRECATED, use [[deprecated]] instead. (open-source-parsers#978)
* delete JSONCPP_DEPRECATED, use [[deprecated]] * add pragma warning(disable:4996) * add error C2416 * update * update * update
1 parent 483eba8 commit b27c83f

File tree

6 files changed

+15
-32
lines changed

6 files changed

+15
-32
lines changed

include/json/config.h

-19
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,6 @@ msvc_pre1900_c99_snprintf(char* outBuf, size_t size, const char* format, ...);
104104
#define JSONCPP_OP_EXPLICIT
105105
#endif
106106

107-
#ifdef __clang__
108-
#if __has_extension(attribute_deprecated_with_message)
109-
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
110-
#endif
111-
#elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
112-
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
113-
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
114-
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
115-
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
116-
#endif // GNUC version
117-
#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
118-
// MSVC)
119-
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
120-
#endif // __clang__ || __GNUC__ || _MSC_VER
121-
122-
#if !defined(JSONCPP_DEPRECATED)
123-
#define JSONCPP_DEPRECATED(message)
124-
#endif // if !defined(JSONCPP_DEPRECATED)
125-
126107
#if defined(__GNUC__) && (__GNUC__ >= 6)
127108
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
128109
#endif

include/json/reader.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@
2525

2626
#pragma pack(push, 8)
2727

28+
#if defined(_MSC_VER)
29+
#pragma warning(disable : 4996)
30+
#endif
31+
2832
namespace Json {
2933

3034
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
3135
* Value.
3236
*
3337
* \deprecated Use CharReader and CharReaderBuilder.
3438
*/
35-
class JSON_API Reader {
39+
class [[deprecated("deprecated Use CharReader and CharReaderBuilder.")]] JSON_API Reader {
3640
public:
3741
typedef char Char;
3842
typedef const Char* Location;
@@ -50,12 +54,10 @@ class JSON_API Reader {
5054

5155
/** \brief Constructs a Reader allowing all features for parsing.
5256
*/
53-
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
5457
Reader();
5558

5659
/** \brief Constructs a Reader allowing the specified feature set for parsing.
5760
*/
58-
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
5961
Reader(const Features& features);
6062

6163
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
@@ -108,7 +110,7 @@ class JSON_API Reader {
108110
* occurred during parsing.
109111
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
110112
*/
111-
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
113+
[[deprecated("Use getFormattedErrorMessages() instead.")]]
112114
String getFormatedErrorMessages() const;
113115

114116
/** \brief Returns a user friendly string that list errors in the parsed

include/json/value.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ class JSON_API Value {
564564
//# endif
565565

566566
/// \deprecated Always pass len.
567-
JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
567+
[[deprecated("Use setComment(String const&) instead.")]]
568568
void setComment(const char* comment, CommentPlacement placement) {
569569
setComment(String(comment, strlen(comment)), placement);
570570
}
@@ -750,7 +750,7 @@ class JSON_API ValueIteratorBase {
750750
/// objectValue.
751751
/// \deprecated This cannot be used for UTF-8 strings, since there can be
752752
/// embedded nulls.
753-
JSONCPP_DEPRECATED("Use `key = name();` instead.")
753+
[[deprecated("Use `key = name();` instead.")]]
754754
char const* memberName() const;
755755
/// Return the member name of the referenced Value, or NULL if it is not an
756756
/// objectValue.

include/json/writer.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
145145
/** \brief Abstract class for writers.
146146
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
147147
*/
148-
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
148+
class [[deprecated("Use StreamWriter instead")]] JSON_API Writer {
149149
public:
150150
virtual ~Writer();
151151

@@ -165,7 +165,7 @@ class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
165165
#pragma warning(push)
166166
#pragma warning(disable : 4996) // Deriving from deprecated class
167167
#endif
168-
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
168+
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API FastWriter
169169
: public Writer {
170170
public:
171171
FastWriter();
@@ -225,7 +225,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
225225
#pragma warning(push)
226226
#pragma warning(disable : 4996) // Deriving from deprecated class
227227
#endif
228-
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
228+
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
229229
StyledWriter : public Writer {
230230
public:
231231
StyledWriter();
@@ -294,7 +294,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
294294
#pragma warning(push)
295295
#pragma warning(disable : 4996) // Deriving from deprecated class
296296
#endif
297-
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
297+
class [[deprecated("Use StreamWriterBuilder instead")]] JSON_API
298298
StyledStreamWriter {
299299
public:
300300
/**

src/test_lib_json/jsontest.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ void Runner::preventDialogOnCrash() {
378378
_CrtSetReportHook(&msvcrtSilentReportHook);
379379
#endif // if defined(_MSC_VER)
380380

381-
// @todo investigate this handler (for buffer overflow)
382-
// _set_security_error_handler
381+
// @todo investigate this handler (for buffer overflow)
382+
// _set_security_error_handler
383383

384384
#if defined(_WIN32)
385385
// Prevents the system from popping a dialog for debugging if the

src/test_lib_json/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ JSONTEST_FIXTURE(IteratorTest, const) {
25222522
Json::Value const v;
25232523
JSONTEST_ASSERT_THROWS(
25242524
Json::Value::iterator it(v.begin()) // Compile, but throw.
2525-
);
2525+
);
25262526

25272527
Json::Value value;
25282528

0 commit comments

Comments
 (0)