aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core/defs.h
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-08-14 12:26:27 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-08-14 15:31:38 +0200
commit6b2621883f4c0ce446bae52198c6169c02efda6b (patch)
treef505a6658e6cbb4d342702dacce03f6597be0824 /include/osmocom/core/defs.h
parent30fbcf5a4134945cb24d50e7fa2151d05241a1f6 (diff)
core: Move OSMO_DEPRECATED to new core/defs.h file
Add a new core/defs.h file for definitions that can be used from within header files without including prototypes and extern declarations. It's primarily meant for macro definitions and basic typedefs. Move the definition of OSMO_DEPRECATED there and use compiler version info to avoid compiler errors.
Diffstat (limited to 'include/osmocom/core/defs.h')
-rw-r--r--include/osmocom/core/defs.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/osmocom/core/defs.h b/include/osmocom/core/defs.h
new file mode 100644
index 00000000..e3afbff2
--- /dev/null
+++ b/include/osmocom/core/defs.h
@@ -0,0 +1,39 @@
+#ifndef OSMOCORE_DEFS_H
+#define OSMOCORE_DEFS_H
+
+/*! \defgroup utils General-purpose utility functions
+ * @{
+ */
+
+/*! \file defs.h
+ * \brief General definitions that are meant to be included from header files.
+ */
+
+/*! \brief Check for gcc and version.
+ *
+ * \note Albeit glibc provides a features.h file that contains a similar
+ * definition (__GNUC_PREREQ), this definition has been copied from there
+ * to have it available with other libraries, too.
+ *
+ * \return != 0 iff gcc is used and it's version is at least maj.min.
+ */
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define OSMO_GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define OSMO_GNUC_PREREQ(maj, min) 0
+#endif
+
+/*! \brief Set the deprecated attribute with a message.
+ */
+#if ! defined(__GNUC__)
+# define OSMO_DEPRECATED(text)
+#elif OSMO_GNUC_PREREQ(4,5)
+# define OSMO_DEPRECATED(text) __attribute__((__deprecated__(text)))
+#else
+# define OSMO_DEPRECATED(text) __attribute__((__deprecated__))
+#endif
+
+/*! @} */
+
+#endif