[glib] Add G_GNUC_DEPRECATED_FOR macro



commit 38e2273207783e4396aabd47bdab5f28155ad6ae
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Apr 6 16:17:18 2010 +0100

    Add G_GNUC_DEPRECATED_FOR macro
    
    It would be good, error reporting-wise, to be able to signal which
    function should be used instead of a deprecated one. GCC 4.5 added an
    optional "message" payload to the deprecated attribute, so that:
    
      void f1 (void) __attribute__((deprecated("Use f2 instead")));
    
    Will expand to:
    
      warning: f1 is deprecated: Use f2 instead
    
    Instead of just printing:
    
      warning: f1 is deprecated
    
    Since we already have a G_GNUC_DEPRECATED macro we should provide a
    G_GNUC_DEPRECATED_FOR macro defined as:
    
      G_GNUC_DEPRECATED_FOR(bar)
    
    Which would expand the deprecation message to "Use bar instead"
    automatically. The deprecation message should probably be similar
    to what we use in gtk-doc to match up with the documentation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=614965

 glib/gmacros.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index b3ff7ee..9f9c25d 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -107,6 +107,13 @@
 #define G_GNUC_DEPRECATED
 #endif /* __GNUC__ */
 
+#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__ */
+
 #if     __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
 #  define G_GNUC_MAY_ALIAS __attribute__((may_alias))
 #else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]