From c51d1a77b04872020234af49384a4ebd22ddd5f0 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 20 May 2014 17:47:13 +0200 Subject: Redo PLIST_WARN_DEPRECATED macro to work with older llvm/clang --- include/plist/Dictionary.h | 2 +- include/plist/plist.h | 40 +++++++++++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h index eee14af..6ad505d 100644 --- a/include/plist/Dictionary.h +++ b/include/plist/Dictionary.h @@ -47,7 +47,7 @@ public : iterator End(); iterator Find(const std::string& key); iterator Set(const std::string& key, Node* node); - DEPRECATED("use Set() instead") iterator Insert(const std::string& key, Node* node); + PLIST_WARN_DEPRECATED("use Set() instead") iterator Insert(const std::string& key, Node* node); void Remove(Node* node); void Remove(const std::string& key); std::string GetNodeKey(Node* key); diff --git a/include/plist/plist.h b/include/plist/plist.h index b855043..f7df832 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -40,21 +40,43 @@ extern "C" typedef unsigned __int64 uint64_t; #ifdef plist_EXPORTS -#define PLIST_API __declspec( dllexport ) + #define PLIST_API __declspec( dllexport ) #else -#define PLIST_API __declspec( dllimport ) + #define PLIST_API __declspec( dllimport ) #endif -#define DEPRECATED(x) __declspec(deprecated(x)) + #else #include #define PLIST_API -#ifdef __GNUC__ -#define DEPRECATED(x) __attribute__((deprecated(x))) +#endif + +#ifdef __llvm__ + #if defined(__has_extension) + #if (__has_extension(attribute_deprecated_with_message)) + #ifndef PLIST_WARN_DEPRECATED + #define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated(x))) + #endif + #else + #ifndef PLIST_WARN_DEPRECATED + #define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated)) + #endif + #endif + #else + #ifndef PLIST_WARN_DEPRECATED + #define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated)) + #endif + #endif +#elif (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 5))) + #ifndef PLIST_WARN_DEPRECATED + #define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated(x))) + #endif #elif defined(_MSC_VER) + #ifndef PLIST_WARN_DEPRECATED + #define PLIST_WARN_DEPRECATED(x) __declspec(deprecated(x)) + #endif #else -#define DEPRECATED(x) -#pragma message("WARNING: You need to implement DEPRECATED for this compiler") -#endif + #define PLIST_WARN_DEPRECATED(x) + #pragma message("WARNING: You need to implement DEPRECATED for this compiler") #endif #include @@ -339,7 +361,7 @@ extern "C" * @param item the new item to insert * @param key The identifier of the item to insert. */ - DEPRECATED("use plist_dict_set_item instead") PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item); + PLIST_WARN_DEPRECATED("use plist_dict_set_item instead") PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item); /** * Remove an existing position in a #PLIST_DICT node. -- cgit v1.1-32-gdbae