[Spice-devel] [protocol v3] macros: Mark unused SPICE_GNUC_XXX macros as deprecated
Francois Gouget
fgouget at codeweavers.com
Thu Dec 15 06:24:57 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>
---
I think v2 would have resulted in all warnings recommending using
G_GNUC_CONST so I added a name parameter:
+#define SPICE_ATTRIBUTE_DEPRECATED(attribute) __attribute__((attribute, warning("deprecated, use -DSPICE_DEPRECATED or G_GNUC_CONST instead")))
spice/macros.h | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/spice/macros.h b/spice/macros.h
index 1f8a5c8..9d4b508 100644
--- a/spice/macros.h
+++ b/spice/macros.h
@@ -33,8 +33,14 @@
#include <spice/types.h>
+#ifndef SPICE_DEPRECATED
+#define SPICE_ATTRIBUTE_DEPRECATED(attribute, name) __attribute__((attribute, warning("deprecated, use -DSPICE_DEPRECATED or " name " instead")))
+#else
+#define SPICE_ATTRIBUTE_DEPRECATED(attribute, name) __attribute__((attribute))
+#endif
+
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-#define SPICE_GNUC_PURE __attribute__((__pure__))
+#define SPICE_GNUC_PURE SPICE_ATTRIBUTE_DEPRECATED(__pure__, "G_GNUC_PURE")
#define SPICE_GNUC_MALLOC __attribute__((__malloc__))
#else
#define SPICE_GNUC_PURE
@@ -42,7 +48,7 @@
#endif
#if __GNUC__ >= 4
-#define SPICE_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
+#define SPICE_GNUC_NULL_TERMINATED SPICE_ATTRIBUTE_DEPRECATED(__sentinel__, "G_GNUC_NULL_TERMINATED")
#else
#define SPICE_GNUC_NULL_TERMINATED
#endif
@@ -62,12 +68,12 @@
#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_SCANF( format_idx, arg_idx ) SPICE_ATTRIBUTE_DEPRECATED(__format__ (__scanf__, format_idx, arg_idx), "G_GNUC_SCANF")
+#define SPICE_GNUC_FORMAT( arg_idx ) SPICE_ATTRIBUTE_DEPRECATED(__format_arg__ (arg_idx), "G_GNUC_FORMAT")
#define SPICE_GNUC_NORETURN __attribute__((__noreturn__))
-#define SPICE_GNUC_CONST __attribute__((__const__))
+#define SPICE_GNUC_CONST SPICE_ATTRIBUTE_DEPRECATED(__const__, "G_GNUC_CONST")
#define SPICE_GNUC_UNUSED __attribute__((__unused__))
-#define SPICE_GNUC_NO_INSTRUMENT __attribute__((__no_instrument_function__))
+#define SPICE_GNUC_NO_INSTRUMENT SPICE_ATTRIBUTE_DEPRECATED(__no_instrument_function__, "G_GNUC_NO_INSTRUMENT")
#else /* !__GNUC__ */
#define SPICE_GNUC_PRINTF( format_idx, arg_idx )
#define SPICE_GNUC_SCANF( format_idx, arg_idx )
--
2.10.2
More information about the Spice-devel
mailing list