[Spice-devel] [protocol] macros: Mark unused SPICE_GNUC_XXX macros as deprecated
Francois Gouget
fgouget at codeweavers.com
Tue Dec 13 05:50:02 UTC 2016
We don't want to maintain more macros than necessary and in the end
the equivalent G_GNUC_XXX macros should be preferred.
Should any project actually depend on these macros they can keep using
them by defining the usual SPICE_DEPRECATED macro until they migrate
away from them or the macros are reinstated.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
Is this what you had in mind?
spice/macros.h | 46 +++++++++++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 13 deletions(-)
diff --git a/spice/macros.h b/spice/macros.h
index 1f8a5c8..29eaf10 100644
--- a/spice/macros.h
+++ b/spice/macros.h
@@ -34,17 +34,25 @@
#include <spice/types.h>
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-#define SPICE_GNUC_PURE __attribute__((__pure__))
#define SPICE_GNUC_MALLOC __attribute__((__malloc__))
#else
-#define SPICE_GNUC_PURE
#define SPICE_GNUC_MALLOC
#endif
-#if __GNUC__ >= 4
-#define SPICE_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#define SPICE_GNUC_PURE
+#elif defined(SPICE_DEPRECATED)
+#define SPICE_GNUC_PURE __attribute__((__pure__))
#else
+#define SPICE_GNUC_PURE __attribute__((__pure__, warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_PURE instead")))
+#endif
+
+#if __GNUC__ < 4
#define SPICE_GNUC_NULL_TERMINATED
+#elif defined(SPICE_DEPRECATED)
+#define SPICE_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
+#else
+#define SPICE_GNUC_NULL_TERMINATED __attribute__((__sentinel__, warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_NULL_TERMINATED instead")))
#endif
#ifndef __has_feature
@@ -62,21 +70,31 @@
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#define SPICE_GNUC_PRINTF( format_idx, arg_idx ) __attribute__((__format__ (__printf__, format_idx, arg_idx)))
-#define SPICE_GNUC_SCANF( format_idx, arg_idx ) __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
-#define SPICE_GNUC_FORMAT( arg_idx ) __attribute__((__format_arg__ (arg_idx)))
#define SPICE_GNUC_NORETURN __attribute__((__noreturn__))
-#define SPICE_GNUC_CONST __attribute__((__const__))
#define SPICE_GNUC_UNUSED __attribute__((__unused__))
-#define SPICE_GNUC_NO_INSTRUMENT __attribute__((__no_instrument_function__))
#else /* !__GNUC__ */
#define SPICE_GNUC_PRINTF( format_idx, arg_idx )
+#define SPICE_GNUC_NORETURN
+#define SPICE_GNUC_UNUSED
+#endif /* !__GNUC__ */
+
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ <= 4)
#define SPICE_GNUC_SCANF( format_idx, arg_idx )
#define SPICE_GNUC_FORMAT( arg_idx )
-#define SPICE_GNUC_NORETURN
#define SPICE_GNUC_CONST
-#define SPICE_GNUC_UNUSED
#define SPICE_GNUC_NO_INSTRUMENT
-#endif /* !__GNUC__ */
+#elif defined(SPICE_DEPRECATED)
+#define SPICE_GNUC_SCANF( format_idx, arg_idx ) __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
+#define SPICE_GNUC_FORMAT( arg_idx ) __attribute__((__format_arg__ (arg_idx)))
+#define SPICE_GNUC_CONST __attribute__((__const__))
+#define SPICE_GNUC_NO_INSTRUMENT __attribute__((__no_instrument_function__))
+#else
+#define SPICE_GNUC_SCANF( format_idx, arg_idx ) __attribute__((__format__ (__scanf__, format_idx, arg_idx), warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_SCANF instead")))
+#define SPICE_GNUC_FORMAT( arg_idx ) __attribute__((__format_arg__ (arg_idx), warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_FORMAT instead")))
+#define SPICE_GNUC_CONST __attribute__((__const__, warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_CONST instead")))
+#define SPICE_GNUC_NO_INSTRUMENT __attribute__((__no_instrument_function__, warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_NO_INSTRUMENT instead")))
+
+#endif
#ifdef G_DEPRECATED
#define SPICE_GNUC_DEPRECATED G_DEPRECATED
@@ -88,10 +106,12 @@
#define SPICE_GNUC_DEPRECATED
#endif
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
+#if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
+# define SPICE_GNUC_MAY_ALIAS
+#elif defined(SPICE_DEPRECATED)
# define SPICE_GNUC_MAY_ALIAS __attribute__((may_alias))
#else
-# define SPICE_GNUC_MAY_ALIAS
+# define SPICE_GNUC_MAY_ALIAS __attribute__((may_alias, warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_MAY_ALIAS instead")))
#endif
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
--
2.10.2
More information about the Spice-devel
mailing list