On 02/09/2020 16:49, Thiago Macieira wrote:
Lars has asked for qsizetype to be defined as the same type (not just the same size) as ptrdiff_t. Effectively, this means defining qint64 as the same type as int64_t. Sounds easy, right?Please remember that qlonglong is the same type in Qt as qint64. That means on these platforms, qlonglong would then be "long", not "long long". This is also reflected in our API: QString::toLongLong and QVariant::toLongLong -- will they return long? Those types are probably also used in a lot of overload sets and could break existing code. Moreover, it could make maintaining Qt5 and Qt6 codebases working together cumbersome. I'm not completely opposed to changing this. But I am asking whether it's worth the trouble.
I'm lacking some context here, why does the definition of qsizetype affect toLongLong? I would imagine that toLongLong functions deal with "long long" no matter what. Why does this prevent making qsizetype == ptrdiff_t?
Tor Arne wrote:As a user of this API I was also stumped by not being able to just call printf with %z and a qsizetype, under the assumption that qsizetype’s purpose in life was to mask_away_ the differences of what a size was represented as.That is indeed why C99 added the "z" and "t" modifiers. But unfortunately we still support one pre-C99 runtime, so you can't use them in cross-platform code.
We're proposing every now and then to drop compilers and platforms for much less, but we do bother with supporting a toolchain that still doesn't implement 20+ years old standards? What's the percentage of users of that one?
For restricted scenarios (MSVC-only or Unix-only code), you can use those modifiers. And in MSVC-only scenarios, there will be no type mismatch either, in both 32- and 64-bit. On 64-bit Unix, the result will be correct too, since the types are the right size. The only thing is you may get a compiler warning that the types mismatched. We could disable -Wformat.
That sounds evil. It catches real bugs (just caught https://codereview.qt-project.org/c/qt/qtbase/+/299726 ).
My 2 c, -- Giuseppe D'Angelo | [email protected] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
