#include <glib/gstdio.h>
#include <glib-object.h>
-#if defined(__clang__) && GLIB_CHECK_VERSION(2, 67, 0)
+#if GLIB_CHECK_VERSION(2, 67, 0)
+
+# if defined(__clang__)
+
/*
* Clang detects (valid) issue in G_DEFINE_TYPE and derivatives starting with
* glib >= 2.67.0. See https://gitlab.gnome.org/GNOME/glib/-/issues/600
* is defined in glib (with a very low probability of being changed thanks to a
* comment above it).
*/
-# undef _G_DEFINE_TYPE_EXTENDED_BEGIN
+# undef _G_DEFINE_TYPE_EXTENDED_BEGIN
-# define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
+# define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-types-discards-qualifiers\"") \
_G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
_Pragma("GCC diagnostic pop")
-#endif /* __clang__ */
+# endif /* __clang__ */
+
+#else /* GLib < 2.67.0 */
+
+/*
+ * ...meanwhile GCC >= 11 has started issuing warnings about volatile
+ * from the old G_DEFINE_TYPE macro impl. IOW the new macros impls fixed
+ * new GCC, but broke CLang
+ */
+# if !defined(__clang__) && __GNUC_PREREQ (11, 0)
+# undef _G_DEFINE_TYPE_EXTENDED_BEGIN
+
+# define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-types\"") \
+ _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
+ _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
+ _Pragma("GCC diagnostic pop")
+# endif /* !clang && GCC >= 11.0 */
+
+#endif /* GLib < 2.67.0 */
gchar * vir_g_canonicalize_filename(const gchar *filename,
const gchar *relative_to);