aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-25 14:31:20 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-25 18:25:31 +0000
commit114d900b011123cbc9cbd79b720105201bae8aa5 (patch)
treead581b36d1452d9fce9127cccdf7dbebea637735
parentf1e89d34ff9af34ebc698904c7f13875f309de10 (diff)
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.6 6.5 6.2 Change-Id: Iacbdf1da3bc1f73757ff5231391ebe847158cc2d Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> (cherry picked from commit fce8fc22efe52b0d8b6f1f4633e8cc64e6641d2c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
index 1f40f0a82..4c13b141f 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())