[Spice-devel,spice-gtk] G_GNUC_DEPRECATED_FOR must be defined publicly

Submitted by Marc-André Lureau on Sept. 7, 2012, 2:59 p.m.

Details

Message ID 1347029971-12869-1-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marc-André Lureau Sept. 7, 2012, 2:59 p.m.
It's not enough to define G_GNUC_DEPRECATED_FOR in glib-compat.h,
since this header is not public. Instead, let's define our own
public SPICE_DEPRECATED_FOR macro, and clean-up double definition.
---
 gtk/glib-compat.h | 16 ----------------
 gtk/spice-util.h  | 12 +++++++++++-
 2 files changed, 11 insertions(+), 17 deletions(-)

Patch hide | download patch | download mbox

diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
index a9efda3..909b4e1 100644
--- a/gtk/glib-compat.h
+++ b/gtk/glib-compat.h
@@ -67,13 +67,6 @@  type_name##_get_type (void) \
 #define G_TYPE_ERROR (spice_error_get_type ())
 GType spice_error_get_type (void) G_GNUC_CONST;
 
-#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-#define G_GNUC_DEPRECATED_FOR(f)                        \
-  __attribute__((deprecated("Use " #f " instead")))
-#else
-#define G_GNUC_DEPRECATED_FOR(f)        G_GNUC_DEPRECATED
-#endif /* __GNUC__ */
-
 #define G_PARAM_DEPRECATED  (1 << 31)
 #endif /* glib 2.26 */
 
@@ -126,13 +119,4 @@  GType spice_main_context_get_type (void) G_GNUC_CONST;
   } G_STMT_END
 #endif
 
-#ifndef G_GNUC_DEPRECATED_FOR
-#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-#define G_GNUC_DEPRECATED_FOR(f)                        \
-  __attribute__((deprecated("Use " #f " instead")))
-#else
-#define G_GNUC_DEPRECATED_FOR(f)        G_GNUC_DEPRECATED
-#endif /* __GNUC__ */
-#endif
-
 #endif /* GLIB_COMPAT_H */
diff --git a/gtk/spice-util.h b/gtk/spice-util.h
index 271f3be..6996e55 100644
--- a/gtk/spice-util.h
+++ b/gtk/spice-util.h
@@ -39,8 +39,18 @@  gulong spice_g_signal_connect_object(gpointer instance,
 
 #define SPICE_RESERVED_PADDING (10 * sizeof(void*))
 
+/* need to be in a public header, glib-compat.h is private */
+#ifndef SPICE_GNUC_DEPRECATED_FOR
+#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define SPICE_GNUC_DEPRECATED_FOR(f)                        \
+  __attribute__((deprecated("Use " #f " instead")))
+#else
+#define SPICE_GNUC_DEPRECATED_FOR(f)        G_GNUC_DEPRECATED
+#endif /* __GNUC__ */
+#endif
+
 #ifndef SPICE_NO_DEPRECATED
-#define SPICE_DEPRECATED_FOR(f)  G_GNUC_DEPRECATED_FOR(f)
+#define SPICE_DEPRECATED_FOR(f)  SPICE_GNUC_DEPRECATED_FOR(f)
 #define SPICE_DEPRECATED  G_GNUC_DEPRECATED
 #else
 #define SPICE_DEPRECATED_FOR(f)

Comments

On Fri, Sep 07, 2012 at 04:59:31PM +0200, Marc-André Lureau wrote:
> It's not enough to define G_GNUC_DEPRECATED_FOR in glib-compat.h,
> since this header is not public. Instead, let's define our own
> public SPICE_DEPRECATED_FOR macro, and clean-up double definition.
> ---
>  gtk/glib-compat.h | 16 ----------------
>  gtk/spice-util.h  | 12 +++++++++++-
>  2 files changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
> index a9efda3..909b4e1 100644
> --- a/gtk/glib-compat.h
> +++ b/gtk/glib-compat.h
> @@ -67,13 +67,6 @@ type_name##_get_type (void) \
>  #define G_TYPE_ERROR (spice_error_get_type ())
>  GType spice_error_get_type (void) G_GNUC_CONST;
>  
> -#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
> -#define G_GNUC_DEPRECATED_FOR(f)                        \
> -  __attribute__((deprecated("Use " #f " instead")))
> -#else
> -#define G_GNUC_DEPRECATED_FOR(f)        G_GNUC_DEPRECATED
> -#endif /* __GNUC__ */
> -
>  #define G_PARAM_DEPRECATED  (1 << 31)
>  #endif /* glib 2.26 */
>  
> @@ -126,13 +119,4 @@ GType spice_main_context_get_type (void) G_GNUC_CONST;
>    } G_STMT_END
>  #endif
>  
> -#ifndef G_GNUC_DEPRECATED_FOR
> -#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
> -#define G_GNUC_DEPRECATED_FOR(f)                        \
> -  __attribute__((deprecated("Use " #f " instead")))
> -#else
> -#define G_GNUC_DEPRECATED_FOR(f)        G_GNUC_DEPRECATED
> -#endif /* __GNUC__ */
> -#endif
> -
>  #endif /* GLIB_COMPAT_H */
> diff --git a/gtk/spice-util.h b/gtk/spice-util.h
> index 271f3be..6996e55 100644
> --- a/gtk/spice-util.h
> +++ b/gtk/spice-util.h
> @@ -39,8 +39,18 @@ gulong spice_g_signal_connect_object(gpointer instance,
>  
>  #define SPICE_RESERVED_PADDING (10 * sizeof(void*))
>  
> +/* need to be in a public header, glib-compat.h is private */
> +#ifndef SPICE_GNUC_DEPRECATED_FOR
> +#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
> +#define SPICE_GNUC_DEPRECATED_FOR(f)                        \
> +  __attribute__((deprecated("Use " #f " instead")))
> +#else
> +#define SPICE_GNUC_DEPRECATED_FOR(f)        G_GNUC_DEPRECATED
> +#endif /* __GNUC__ */
> +#endif
> +

Looks good, ACK, just wondering if we should try to reuse
G_GNUC_DEPRECATED_FOR as much as possible, something like:
#ifndef SPICE_GNUC_DEPRECATED_FOR
 #ifdef G_GNUC_DEPRECATED_FOR
  #define SPICE_GNUC_DEPRECATED_FOR G_GNUC_DEPRECATED_FOR
 #else
  #if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
   #define SPICE_GNUC_DEPRECATED_FOR(f)                        \
     __attribute__((deprecated("Use " #f " instead")))
...

I'm fine with the patch as it is now.

Christophe