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.
This commit is contained in:
Chun-wei Fan 2022-02-14 18:26:13 +08:00
parent 6ee71750a5
commit 87db363501

View File

@ -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