mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-27 09:36:53 +02:00
macros: Double-cast func for g_autolist to avoid warning
For g_autolist and g_autoslist, the cleanup func was cast to GDestroyNotify before being passed to g_(s)list_free_full. This cast provokes GCC 8 to emit a warning if the return type is not void: …/gmacros.h:462:99: warning: cast between incompatible function types from … to 'void (*)(void *)' [-Wcast-function-type] Cast to 'void (*)(void)' first, which suppresses the warning as recommended by the GCC documentation. g_autoptr remains untouched. Fixes https://gitlab.gnome.org/GNOME/glib/issues/1382
This commit is contained in:
parent
b41bff1fe9
commit
c7d11d3418
@ -483,8 +483,8 @@
|
|||||||
typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \
|
typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
||||||
static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \
|
static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \
|
||||||
static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) func); } \
|
static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) (void(*)(void)) func); } \
|
||||||
static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) func); } \
|
static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) (void(*)(void)) func); } \
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||||
#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \
|
#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef struct _HNVC HasNonVoidCleanup;
|
||||||
|
HasNonVoidCleanup * non_void_cleanup (HasNonVoidCleanup *);
|
||||||
|
|
||||||
|
/* Should not cause any warnings with -Wextra */
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(HasNonVoidCleanup, non_void_cleanup)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_autofree (void)
|
test_autofree (void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user