From c575977645ece4b8d1e6aaec21daa043da5affa8 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 24 Jul 2018 12:36:06 +0200 Subject: [PATCH] Fix MSVC builds with /Zc:wchar_t- 208c71768 introduced a problem for our users, who build on Windows with /Zc:wchar_t-, which makes wchar_t a typedef for the type 'unsigned short', preventing them from switching to more recent versions of Qt. While MSDN recommends against this option, we can add more #if-ery to avoid compiler's bailing out on a constructor's redefinition. Task-number: QTBUG-65101 Change-Id: I62a1d9b2572f3d4b1f70bcbc3e52e795b1944558 Reviewed-by: Friedemann Kleint --- src/corelib/tools/qchar.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 84df8accc5..8590b91ba3 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -93,7 +93,9 @@ public: Q_STATIC_ASSERT(sizeof(wchar_t) == sizeof(ushort)); #endif #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +# if !defined(_WCHAR_T_DEFINED) || defined(_NATIVE_WCHAR_T_DEFINED) Q_DECL_CONSTEXPR QChar(wchar_t ch) Q_DECL_NOTHROW : ucs(ushort(ch)) {} // implicit +# endif #endif #ifndef QT_NO_CAST_FROM_ASCII