[Spice-devel] [protocol] macros: Mark unused SPICE_GNUC_XXX macros as deprecated

Francois Gouget fgouget at codeweavers.com
Fri Jun 21 15:29:09 UTC 2019


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 noticed that this patch fell off despite what looked like general 
agreement. I re-grepped for these macros and did not find them used in 
the current Spice codebase which means they have not been used for at 
least two years.

https://lists.freedesktop.org/archives/spice-devel/2016-December/034578.html

 spice/macros.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/spice/macros.h b/spice/macros.h
index ab1d056..95c12d4 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.20.1


More information about the Spice-devel mailing list