From eff0cdf2cdda70135a7c0d5e00fe10f2c399b304 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 25 Mar 2024 14:31:20 +0100 Subject: Fix build with MSVC Add /Zc:__cplusplus, fixing: QtCore/qcompilerdetection.h(1257): fatal error C1189: #error: "Qt requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." Also update the emulated MSVC version for libclang 18. Pick-to: 6.5 6.2 Change-Id: Iacbdf1da3bc1f73757ff5231391ebe847158cc2d Reviewed-by: Adrian Herrmann (cherry picked from commit fce8fc22efe52b0d8b6f1f4633e8cc64e6641d2c) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 114d900b011123cbc9cbd79b720105201bae8aa5) --- sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp index b3cce9e86..e8250f900 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp @@ -94,6 +94,12 @@ bool setPlatform(const QString &name) return result; } +// 3/2024: Use a recent MSVC2022 for libclang 18.X +static QByteArray msvcCompatVersion() +{ + return libClangVersion() >= QVersionNumber(0, 64) ? "19.39"_ba : "19.26"_ba; +} + static bool runProcess(const QString &program, const QStringList &arguments, QByteArray *stdOutIn = nullptr, QByteArray *stdErrIn = nullptr) { @@ -365,9 +371,10 @@ QByteArrayList emulatedCompilerOptions() HeaderPaths headerPaths; switch (compiler()) { case Compiler::Msvc: - result.append(QByteArrayLiteral("-fms-compatibility-version=19.26.28806")); + result.append("-fms-compatibility-version="_ba + msvcCompatVersion()); result.append(QByteArrayLiteral("-fdelayed-template-parsing")); result.append(QByteArrayLiteral("-Wno-microsoft-enum-value")); + result.append("/Zc:__cplusplus"_ba); // Fix yvals_core.h: STL1000: Unexpected compiler version, expected Clang 7 or newer (MSVC2017 update) result.append(QByteArrayLiteral("-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH")); if (needsClangBuiltinIncludes()) -- cgit v1.2.3