[PATCH 1/2] core: Support clang with OSME_DEPRECATED

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Wed Aug 14 16:13:45 UTC 2013


Separate feature checking from implementation. Supported are clang and
gcc.
---
 include/osmocom/core/defs.h |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/osmocom/core/defs.h b/include/osmocom/core/defs.h
index e3afbff..917a8c3 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
-- 
1.7.9.5





More information about the OpenBSC mailing list