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 +#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'; diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 4175b6c849..0b44b83a88 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -1,14 +1,6 @@ // Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -// Don't define it while compiling this module, or USERS of Qt will -// not be able to link. -#ifdef QT_NO_CAST_FROM_ASCII -# undef QT_NO_CAST_FROM_ASCII -#endif -#ifdef QT_NO_CAST_TO_ASCII -# undef QT_NO_CAST_TO_ASCII -#endif #include "qchar.h" #include "qdatastream.h" diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 6ebd7debed..af77f5d5d3 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -51,6 +51,11 @@ #ifdef Q_OS_WIN # include +# if !defined(QT_BOOTSTRAPPED) && (defined(QT_NO_CAST_FROM_ASCII) || defined(QT_NO_CAST_TO_ASCII)) +// 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 QString functions will not get exported." +# endif #endif #ifdef truncate