[Development] Is qsizetype *documented* to be ptrdiff_t?

Mathias Hasselmann mathias at taschenorakel.de
Wed Sep 2 09:15:37 CEST 2020

I'd rather say that cast is entirely ugly. Seems like a perfect example 
or code smell: Something is fundamentally wrong they way qsizetype is 

Am 01.09.2020 um 19:29 schrieb Thiago Macieira:
> On Tuesday, 1 September 2020 08:44:07 PDT Giuseppe D'Angelo via Development
> wrote:
>> Il 01/09/20 16:23, Thiago Macieira ha scritto:
>>> So even if you use %td or %zd, GCC will complain in one of three different
>>> platform configurations (namely, 64-bit Unix).
>> Pedantically, do we need the PRIxQSS (?) macro and friends to use
>> qsizetype into qWarning etc.?
> That's ugly. Just cast the type itself to ptrdiff_t or int.
> That is, write:
>      qWarning("List too big: %zd", ptrdiff_t(list.size());
> Qt's internal sprintf-like functions actually use qsizetype, not ptrdiff_t, so
> pedantically-strictly speaking the compiler is wrong and your code was right
> without the cast. In real-life, it just works.
> Note: this only applies to the functions that actually use Qt's own sprintf-
> like functions. You can't use with printf family itself because we still
> support MinGW and that one uses a C99-incompatible standard library by default
> (no "z" and no "t" modifier and no 64-bit support on 32-bit systems).

More information about the Development mailing list