diff options
author | Dan Winship <danw@gnome.org> | 2012-02-10 08:49:17 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-02-15 09:54:38 -0500 |
commit | ca05902a5883020add334e542a63d7f9381a3117 (patch) | |
tree | 961b8275bbe6b104dd06e885a11ac0e03f25abf7 /glib | |
parent | ab59739e1177d463fc7577def059deb0179662cc (diff) | |
download | glib-ca05902a5883020add334e542a63d7f9381a3117.tar.gz |
Add G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS
Add new macros to disable -Wdeprecated-declarations around a piece of
code, using the C99 (and GNU89) _Pragma() operator. Replace the
existing use of #pragma for this in gio, and suppress the warnings in
gvaluearray.c as well.
https://bugzilla.gnome.org/show_bug.cgi?id=669671
Diffstat (limited to 'glib')
-rw-r--r-- | glib/docs.c | 33 | ||||
-rw-r--r-- | glib/gmacros.h | 11 |
2 files changed, 44 insertions, 0 deletions
diff --git a/glib/docs.c b/glib/docs.c index 97d41cd42..f680ae071 100644 --- a/glib/docs.c +++ b/glib/docs.c @@ -1987,6 +1987,39 @@ */ /** + * G_GNUC_BEGIN_IGNORE_DEPRECATIONS: + * + * Tells <command>gcc</command> (if it is a new enough version) to + * temporarily stop emitting warnings when functions marked with + * %G_GNUC_DEPRECATED or %G_GNUC_DEPRECATED_FOR are called. This is + * useful for when you have one deprecated function calling another + * one, or when you still have regression tests for deprecated + * functions. + * + * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you + * are not compiling with <literal>-Wdeprecated-declarations</literal> + * then neither macro has any effect.) + * + * This macro can be used either inside or outside of a function body, + * but must appear on a line by itself. + * + * Since: 2.32 + */ + +/** + * G_GNUC_END_IGNORE_DEPRECATIONS: + * + * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling + * <command>gcc</command> to begin outputting warnings again + * (assuming those warnings had been enabled to begin with). + * + * This macro can be used either inside or outside of a function body, + * but must appear on a line by itself. + * + * Since: 2.32 + */ + +/** * G_GNUC_NORETURN: * * Expands to the GNU C <literal>noreturn</literal> function attribute diff --git a/glib/gmacros.h b/glib/gmacros.h index 2b340cb0d..e07610ccb 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -114,6 +114,17 @@ #define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED #endif /* __GNUC__ */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic pop") +#else +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS +#define G_GNUC_END_IGNORE_DEPRECATIONS +#endif + #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) # define G_GNUC_MAY_ALIAS __attribute__((may_alias)) #else |