From 38b82ba16017bd6e56005d04ef00352ccc5d529e Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 2 Aug 2024 13:19:47 +0200 Subject: [PATCH] Use new MSVC preprocessor for VS 17 builds From the documentation[1]: | We're updating the Microsoft C++ preprocessor to improve standards | conformance, fix longstanding bugs, and change some behaviors that | are officially undefined. We've also added new diagnostics to warn | on errors in macro definitions. Thus it appears to be sensible to switch to the new preprocessor for all VS17 builds. Note that although the new preprocessor is available as of VS16.5 (i.e. `version >= 1925`), we don't want to potentially break older builds, and as such use the new preprocessor only for VS17 builds. Users who wish to use the new preprocessor with VS16, can still `set CFLAGS=/Zc:preprocessor` before running `buildconf`/`phpize`. [1] --- win32/build/confutils.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 2288a23888aa8..4495ed73c04d2 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3313,6 +3313,10 @@ function toolset_setup_common_cflags() ADD_FLAG("CFLAGS", "/d2FuncCache1"); } + if (VCVERS >= 1930) { + ADD_FLAG("CFLAGS", "/Zc:preprocessor"); + } + ADD_FLAG("CFLAGS", "/Zc:wchar_t"); } else if (CLANG_TOOLSET) { if (TARGET_ARCH == 'x86') {