[glib/gconstructor-h-fix] gconstructor.h: Visual Studio: Only include glist.h if needed




commit f543871cd50acb93062a58a30867061389f48788
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Feb 14 18:26:13 2022 +0800

    gconstructor.h: Visual Studio: Only include glist.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 <stdlib.h>
 
 #define G_HAS_CONSTRUCTORS 1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]