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

Thiago Macieira thiago.macieira at intel.com
Thu Sep 3 06:08:06 CEST 2020

On Wednesday, 2 September 2020 19:25:39 PDT Giuseppe D'Angelo via Development 
> 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?

Because qsizetype is the same type as qint64, which is the same type as 
qlonglong (which exists for historical reasons, because older VC++ didn't 
support "long long").

I don't have a problem changing the actual type those are aliases of. But I do 
have a problem making them different types. A lot of code assumes that qint64 
and qlonglong are the same type. While they're always the same size, having 
them be different types could result in warnings and problems with overload 

For example, say I've added QRandomGenerator::bounded(qint64) and quint64.

  qint64 v = QRandomGenerator::system()->bounded(str.toLongLong());

Does this compile or not?

> > 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?

Since we're talking about MinGW, I think it's considerable.

I've done some research on this, though not as deeply as is required to come 
to a conclusion. MinGW can use one of three printf family implementations:

- the default: msvcrt.dll / crtdll.dll, which is effectively unchanged since 
  Windows 95 (even the 64-bit version, which was first released in 2005)
- the one in libmingwex-0.dll
- the Windows 10 Universal CRT

The default has the advantage that it is present on every single Windows 
system, so there's no extra DLL that one needs to ship. The Universal CRT is 
the long-term solution, but clearly requires Windows 10. The portable MinGW 
extension library can be used to get a modern runtime on older Windows.

Except that UCRT is not completely supported yet. The compiler itself needs to 
be patched to pass a different set of libraries to the linker.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering

More information about the Development mailing list