From 87db3635016752abe1ee1a58ce4c7c61e9a13ee6 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 14 Feb 2022 18:26:13 +0800 Subject: [PATCH] gconstructor.h: Visual Studio: Only include gslist.h if needed We only want to include gslist.h here if it was not already included via including glib.h, as: * gslist.h should normally be included via glib.h if used outside of GLib itself. * This broke Visual Studio builds that use GResources (via glib-compile-resources.exe) as that would cause the generated code to include gslist.h directly, which is therefore disallowed. --- glib/gconstructor.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glib/gconstructor.h b/glib/gconstructor.h index 17c46699a..c5e0dfaa6 100644 --- a/glib/gconstructor.h +++ b/glib/gconstructor.h @@ -55,7 +55,15 @@ #elif defined (_MSC_VER) && (_MSC_VER >= 1500) /* Visual studio 2008 and later has _Pragma */ +/* + * Only try to include gslist.h if not already included via glib.h, + * so that items using gconstructor.h outside of GLib (such as + * GResources) continue to build properly. + */ +#ifndef __G_LIB_H__ #include "gslist.h" +#endif + #include #define G_HAS_CONSTRUCTORS 1