From 994209dbeec58098b53a028ef54660e67147c9ae Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 20 Feb 2023 18:50:01 +0800 Subject: [PATCH] gstring.h: Avoid compiler warning on Visual Studio The recent optimizations to gstring.h used G_ALWAYS_INLINE (meaning '__forceinline' on Visual Studio) together with 'static inline', which will cause warning C4141 indicating that 'inline' was used more than once on the function. Avoid this by temporarily disabling warning C4141 in gstring.h when building the code that uses 'G_ALWAYS_INLINE'. Fixes issue #2905. --- glib/gstring.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/glib/gstring.h b/glib/gstring.h index 55825c012..859668716 100644 --- a/glib/gstring.h +++ b/glib/gstring.h @@ -179,9 +179,15 @@ GString* g_string_append_uri_escaped (GString *string, const gchar *reserved_chars_allowed, gboolean allow_utf8); +#ifdef G_CAN_INLINE + +#if defined (_MSC_VER) && !defined (__clang__) +#pragma warning (push) +#pragma warning (disable : 4141) /* silence "warning C4141: 'inline' used more than once" */ +#endif + #ifndef __GTK_DOC_IGNORE__ -#ifdef G_CAN_INLINE G_ALWAYS_INLINE static inline GString* g_string_append_c_inline (GString *gstring, @@ -267,10 +273,14 @@ g_string_truncate_inline (GString *gstring, #endif /* G_GNUC_CHECK_VERSION (2, 0) */ -#endif /* G_CAN_INLINE */ - #endif /* __GTK_DOC_IGNORE__ */ +#if defined (_MSC_VER) && !defined (__clang__) +#pragma warning (pop) /* #pragma warning (disable : 4141) */ +#endif + +#endif /* G_CAN_INLINE */ + GLIB_DEPRECATED GString *g_string_down (GString *string); GLIB_DEPRECATED