From d24651d548d6f86f988dd28ccfe2370f4af75765 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Tue, 12 Oct 2021 09:21:03 +0200 Subject: [PATCH] Guard WinRT API code for clang-cl It is unsupported with clang-cl and breaks the build. This is a fixup for: 51e8d3592a Let QLocale::uiLanguages() use WinRT API when possible Task-number: QTBUG-94341 Pick-to: 6.2 Change-Id: Icf32339e81d67d4c119b7fb8d8d834c744b9ead0 Reviewed-by: Edward Welbourne Reviewed-by: Ivan Solovev Reviewed-by: Thiago Macieira --- src/corelib/CMakeLists.txt | 3 ++- src/corelib/text/qlocale_win.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 3df996bc623..1f760cbd3aa 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -796,7 +796,8 @@ qt_internal_extend_target(Core CONDITION WIN32 text/qlocale_win.cpp ) -qt_internal_extend_target(Core CONDITION WIN32 AND MSVC +# On MS-Win, clang has two flavors, one of which immitates MSVC (so claims to be it) +qt_internal_extend_target(Core CONDITION WIN32 AND MSVC AND NOT CLANG LIBRARIES runtimeobject ) diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index d2dd07e5497..191533c8863 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -51,7 +51,7 @@ # include #endif -#if defined(Q_CC_MSVC) +#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) # include // Workaround for Windows SDK bug. // See https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47 @@ -63,7 +63,7 @@ namespace winrt::impl # include # include # include -#endif // defined(Q_CC_MSVC) +#endif // defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) QT_BEGIN_NAMESPACE @@ -630,7 +630,7 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS QVariant QSystemLocalePrivate::uiLanguages() { QStringList result; -#if defined(Q_CC_MSVC) // msvc supports WinRT calls +#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) // msvc supports WinRT calls using namespace winrt; using namespace Windows::Foundation; using namespace Windows::System::UserProfile; @@ -639,7 +639,7 @@ QVariant QSystemLocalePrivate::uiLanguages() result << QString::fromStdString(winrt::to_string(lang)); if (!result.isEmpty()) return result; // else just fall back to WIN32 API implementation -#endif // defined(Q_CC_MSVC) +#endif // defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) // mingw and clang still have to use Win32 API unsigned long cnt = 0; QVarLengthArray buf(64);