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 <Friedemann.Kleint@qt.io>
This commit is contained in:
Timur Pocheptsov 2018-07-24 12:36:06 +02:00
parent ad8a7f0c50
commit c575977645

View File

@ -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