diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index b68090365b8..6b04bc92cd1 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -807,15 +807,16 @@ QByteArray qdtoAscii(double d, QLocaleData::DoubleForm form, int precision, bool return dtoString(d, form, precision, uppercase); } -#if defined(QT_SUPPORTS_INT128) || (defined(Q_CC_MSVC) && (_MSC_VER >= 1930)) +#if defined(QT_SUPPORTS_INT128) || defined(QT_USE_MSVC_INT128) static inline quint64 toUInt64(qinternaluint128 v) { -#ifdef QT_SUPPORTS_INT128 - return quint64(v); -#elif defined(Q_CC_MSVC) +#if defined(QT_USE_MSVC_INT128) return quint64(v._Word[0]); +#else + return quint64(v); #endif } + QString quint128toBasicLatin(qinternaluint128 number, int base) { // We divide our 128-bit number into parts that we can do text @@ -879,6 +880,6 @@ QString qint128toBasicLatin(qinternalint128 number, int base) result.prepend(u'-'); return result; } -#endif // defined(QT_SUPPORTS_INT128) || (defined(Q_CC_MSVC) && (_MSC_VER >= 1930)) +#endif // defined(QT_SUPPORTS_INT128) || defined(QT_USE_MSVC_INT128) QT_END_NAMESPACE diff --git a/src/corelib/text/qlocale_tools_p.h b/src/corelib/text/qlocale_tools_p.h index 9ae9dc8de74..2cfe25d2997 100644 --- a/src/corelib/text/qlocale_tools_p.h +++ b/src/corelib/text/qlocale_tools_p.h @@ -18,8 +18,9 @@ #include "qlocale_p.h" #include "qstring.h" -#if !defined(QT_SUPPORTS_INT128) && defined(Q_CC_MSVC) && (_MSC_VER >= 1930) +#if !defined(QT_SUPPORTS_INT128) && (defined(Q_CC_MSVC) && (_MSC_VER >= 1930) && __has_include(<__msvc_int128.hpp>)) #include <__msvc_int128.hpp> +#define QT_USE_MSVC_INT128 #endif QT_BEGIN_NAMESPACE @@ -27,7 +28,7 @@ QT_BEGIN_NAMESPACE #if defined(QT_SUPPORTS_INT128) using qinternalint128 = qint128; using qinternaluint128 = quint128; -#elif defined(Q_CC_MSVC) && (_MSC_VER >= 1930) +#elif defined(QT_USE_MSVC_INT128) using qinternalint128 = std::_Signed128; using qinternaluint128 = std::_Unsigned128; #endif @@ -55,7 +56,7 @@ void qt_doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, [[nodiscard]] QByteArray qdtoAscii(double d, QLocaleData::DoubleForm form, int precision, bool uppercase); -#if defined(QT_SUPPORTS_INT128) || (defined(Q_CC_MSVC) && (_MSC_VER >= 1930)) +#if defined(QT_SUPPORTS_INT128) || defined(QT_USE_MSVC_INT128) [[nodiscard]] Q_CORE_EXPORT QString quint128toBasicLatin(qinternaluint128 number, int base = 10); [[nodiscard]] Q_CORE_EXPORT QString qint128toBasicLatin(qinternalint128 number,