summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/core/defs.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/include/osmocom/core/defs.h b/include/osmocom/core/defs.h
index e3afbff2..917a8c3a 100644
--- a/include/osmocom/core/defs.h
+++ b/include/osmocom/core/defs.h
@@ -26,14 +26,25 @@
/*! \brief Set the deprecated attribute with a message.
*/
-#if ! defined(__GNUC__)
-# define OSMO_DEPRECATED(text)
-#elif OSMO_GNUC_PREREQ(4,5)
+#if defined(__clang__)
+# define _OSMO_HAS_ATTRIBUTE_DEPRECATED __has_attribute(deprecated)
+# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE __has_extension(attribute_deprecated_with_message)
+#elif defined(__GNUC__)
+# define _OSMO_HAS_ATTRIBUTE_DEPRECATED 1
+# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE OSMO_GNUC_PREREQ(4,5)
+#endif
+
+#if defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE)
# define OSMO_DEPRECATED(text) __attribute__((__deprecated__(text)))
-#else
+#elif defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED)
# define OSMO_DEPRECATED(text) __attribute__((__deprecated__))
+#else
+# define OSMO_DEPRECATED(text)
#endif
+#undef _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE
+#undef _OSMO_HAS_ATTRIBUTE_DEPRECATED
+
/*! @} */
#endif