From c0385e978ae2b0592029d35fd40cc28aa088dce1 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 8 Dec 2024 23:42:34 +0100 Subject: [PATCH] Guard config.w32.h from multiple inclusion (GH-17021) Besides that is generally good practice to avoid macro redefinitions (and symbol redeclarations), and we're doing this on POSIX platforms anyway, there is a particular issue regarding phpize builds, where config.w32.h actually includes config.pickle.h. The latter overrides some macro definitions (e.g. `PHP_BUILD_SYSTEM`) to define the proper values, but if config.w32.h is included multiple times, different macro definitions eventually raise C4005 compiler warnings[1], which break builds with `/WX /W1` enabled. [1] --- win32/build/confutils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index c44a607af1c..438eb1d239c 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2272,6 +2272,10 @@ function generate_config_h() outfile = FSO.CreateTextFile("main/config.w32.h", true); + outfile.WriteLine("#ifndef CONFIG_W32_H"); + outfile.WriteLine("#define CONFIG_W32_H"); + outfile.WriteBlankLines(1); + indata = indata.replace(new RegExp("@PREFIX@", "g"), prefix); outfile.Write(indata); @@ -2319,6 +2323,8 @@ function generate_config_h() outfile.WriteLine("#if __has_include(\"main/config.pickle.h\")"); outfile.WriteLine("#include \"main/config.pickle.h\""); outfile.WriteLine("#endif"); + outfile.WriteBlankLines(1); + outfile.WriteLine("#endif /* CONFIG_W32_H */"); outfile.Close(); }