diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2024-01-22 09:04:46 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-01-23 10:08:23 -0800 |
commit | 62de01bf178a2ce629cf64cc73edcd2d88d8eeba (patch) | |
tree | 820b3f0ffc2e7fc51d06f7aae26aa7e860ab2108 /src/corelib/text/qbytearray.cpp | |
parent | QHostInfo: fix lookupHost() signature immediately (diff) | |
download | qtbase-62de01bf178a2ce629cf64cc73edcd2d88d8eeba.tar.xz qtbase-62de01bf178a2ce629cf64cc73edcd2d88d8eeba.zip |
QString & QByteArray: ensure QT_NO_CAST_* are not defined on Windows
We can't have those macros defined while compiling the headers on
Windows (mainly MSVC, but there are some corner cases that apply to
MinGW too) because the inline functions must be emitted and added to the
DLL export table. Trying to undefine (as qchar.cpp did) won't work in
builds with PCH or in CMake Unified builds, because the headers in
question will have already been included. So instead just #error out.
qchar.cpp is #included in qstring.cpp so it no longer needs this. For Qt
7, we'll un-export the class (see next commit).
Note: it's possible we only need a single .cpp including the headers and
compiled without these macros for the export to kick in. That could be
removed_api.cpp, because that can never be part of PCH or Unified
sources. But I have not confirmed this is the case.
Task-number: QTBUG-121356
Change-Id: I5dd50a1a7ca5424d9e7afffd17acba32fb27f1ca
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 1ff2721265..b13708752d 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -34,6 +34,14 @@ #include <algorithm> +#ifdef Q_OS_WIN +# if !defined(QT_BOOTSTRAPPED) && (defined(QT_NO_CAST_FROM_ASCII) || defined(QT_NO_CAST_FROM_BYTEARRAY)) +// MSVC requires this, but let's apply it to MinGW compilers too, just in case +# error "This file cannot be compiled with QT_NO_CAST_{TO,FROM}_ASCII, " \ + "otherwise some QByteArray functions will not get exported." +# endif +#endif + QT_BEGIN_NAMESPACE Q_CONSTINIT const char QByteArray::_empty = '\0'; |