From fb7b08388e9de5440962337e20a823bbf9d019ae Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 25 Aug 2014 18:27:38 +0200 Subject: glib-compat: fix compatibility wrapper for g_type_ensure() The previous implementaiton of the compatibility wrapper failed with clang when used inside a macro. This seems like a compiler error not to ignore the deprecation. Workaround by refactoring the g_type_ensure() wrapper. Signed-off-by: Thomas Haller --- include/nm-glib-compat.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h index c8f1b5f11c..397eabfaca 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -43,13 +43,21 @@ #include "nm-gvaluearray-compat.h" -#if !GLIB_CHECK_VERSION(2,34,0) static inline void -g_type_ensure (GType type) +__g_type_ensure (GType type) { - if (G_UNLIKELY (type == (GType)-1)) - g_error ("can't happen"); +#if !GLIB_CHECK_VERSION(2,34,0) + if (G_UNLIKELY (type == (GType)-1)) + g_error ("can't happen"); +#else + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + g_type_ensure (type); + G_GNUC_END_IGNORE_DEPRECATIONS; +#endif } +#define g_type_ensure __g_type_ensure + +#if !GLIB_CHECK_VERSION(2,34,0) #define g_clear_pointer(pp, destroy) \ G_STMT_START { \ @@ -82,13 +90,6 @@ g_type_ensure (GType type) * the APIs that we emulate above. */ -#define g_type_ensure(t) \ - G_STMT_START { \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_type_ensure (t); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - } G_STMT_END - #define g_test_expect_message(domain, level, format...) \ G_STMT_START { \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ -- cgit v1.2.1