mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
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
This commit is contained in:
parent
ab59739e11
commit
ca05902a58
@ -336,6 +336,8 @@ G_GNUC_ALLOC_SIZE
|
||||
G_GNUC_ALLOC_SIZE2
|
||||
G_GNUC_DEPRECATED
|
||||
G_GNUC_DEPRECATED_FOR
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
G_GNUC_NORETURN
|
||||
G_GNUC_UNUSED
|
||||
G_GNUC_PRINTF
|
||||
|
@ -3352,6 +3352,8 @@ get_all_desktop_entries_for_mime_type (const char *base_mime_type,
|
||||
|
||||
/* GDesktopAppInfoLookup interface: */
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef GDesktopAppInfoLookupIface GDesktopAppInfoLookupInterface;
|
||||
G_DEFINE_INTERFACE (GDesktopAppInfoLookup, g_desktop_app_info_lookup, G_TYPE_OBJECT)
|
||||
|
||||
@ -3378,8 +3380,6 @@ g_desktop_app_info_lookup_default_init (GDesktopAppInfoLookupInterface *iface)
|
||||
*
|
||||
* Deprecated: The #GDesktopAppInfoLookup interface is deprecated and unused by gio.
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
GAppInfo *
|
||||
g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup,
|
||||
const char *uri_scheme)
|
||||
@ -3392,4 +3392,5 @@ g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *loo
|
||||
|
||||
return (* iface->get_default_for_uri_scheme) (lookup, uri_scheme);
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
@ -809,8 +809,6 @@ DllMain (HINSTANCE hinstDLL,
|
||||
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
void
|
||||
_g_io_modules_ensure_extension_points_registered (void)
|
||||
{
|
||||
@ -826,7 +824,9 @@ _g_io_modules_ensure_extension_points_registered (void)
|
||||
#ifdef G_OS_UNIX
|
||||
#if !GLIB_CHECK_VERSION (3, 0, 0)
|
||||
ep = g_io_extension_point_register (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_io_extension_point_set_required_type (ep, G_TYPE_DESKTOP_APP_INFO_LOOKUP);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -863,7 +863,6 @@ _g_io_modules_ensure_extension_points_registered (void)
|
||||
|
||||
G_UNLOCK (registered_extensions);
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void
|
||||
_g_io_modules_ensure_loaded (void)
|
||||
|
33
glib/docs.c
33
glib/docs.c
@ -1986,6 +1986,39 @@
|
||||
* Since: 2.26
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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:
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -228,7 +228,9 @@ g_value_array_prepend (GValueArray *value_array,
|
||||
{
|
||||
g_return_val_if_fail (value_array != NULL, NULL);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
return g_value_array_insert (value_array, 0, value);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,7 +251,9 @@ g_value_array_append (GValueArray *value_array,
|
||||
{
|
||||
g_return_val_if_fail (value_array != NULL, NULL);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
return g_value_array_insert (value_array, value_array->n_values, value);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user