qt5base-lts/tests/auto
Giuseppe D'Angelo 5fabad9a61 Long live PRI*Qdatatypes
Qt defines some integral datatypes (qsizetype, qintptr, quintptr,
qptrdiff) not in terms of the corresponding language datatypes (resp.
make_signed_t<size_t>, intptr_t, uintptr_t, ptrdiff_t) but as "integer
types with the same bit size of the corresponding language type" (and of
course the corret correct signedness for the target type).

This makes the Qt datatypes not printable via printf-like formatted
output, incl. qDebug, qWarning, QString::asprintf and so on; that's
because there isn't a format modifier that would universally work
with the Qt definitions.

For instance, on a 32 bit platform, ptrdiff_t may be a typedef for long,
while qptrdiff is a typedef for _int_ instead. Both long and int would
indeed be 32 bits, but they still are different types, and this means
that the ptrdiff_t-specific 't' length modifier would be wrong for
qptrdiff:

  qptrdiff p;
  printf("%td", p); // WARNING: -Wformat: wanted long, got int

Similarly, not using 't' breaks on 64 bits, and so on and so forth.
There isn't a way out, short of inserting casts on every print
statement.

So, let's adopt the same solution C/C++ use for their own integer
typedefs: the PRIx macros. This allows one to always use the correct
formatting specifier without the need of a cast.

I'm not adding the macros for the qintXX datatypes, as they already
exist in the Standard Library.

[ChangeLog][QtCore][QtGlobal] A series of PRIxQTDATATYPE macros have
been added. They make it possible to print some Qt type aliases
(qsizetype, qintptr, etc.) via a formatted output facility such as
printf() or qDebug() without raising formatting warnings and without
the need of a type cast.

Change-Id: I473226a661868aed9514d793c8e6e4d391ab5055
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-04-25 15:24:45 +02:00
..
bic/data Add binary compatibility files for Qt 6.0.0 2021-04-08 06:34:13 +00:00
cmake fix: The QtStartUpFunction function may be called repeatedly 2021-04-23 18:51:30 +02:00
concurrent Fix gcc warnings from having only one of assignment/copy 2021-04-11 19:53:51 +02:00
corelib Long live PRI*Qdatatypes 2021-04-25 15:24:45 +02:00
dbus Port of QDBusServiceWatcher::watchMode to new property system 2021-04-19 15:18:46 +02:00
gui Fix tst_qicon for fractional dpr 2021-04-20 21:33:00 +02:00
guiapplauncher Move QStateMachine from QtCore to QtScxml 2020-08-24 20:10:25 +02:00
network Move plugin code from QtNetwork to qtbase/plugins 2021-04-22 22:51:54 +02:00
opengl Remove the qmake project files 2021-01-07 15:32:28 +01:00
other QObject: port to new property system 2021-04-21 15:34:28 +02:00
printsupport Remove the qmake project files 2021-01-07 15:32:28 +01:00
shared Remove false Q_UNREACHABLE from shaping code 2021-02-03 09:44:44 +01:00
sql SQLite: Handle tables and fields with a dot in the name correctly 2021-04-23 10:46:58 +02:00
testlib Fix QAbstractItemModelTester false positive 2021-04-19 19:30:46 +01:00
tools Silence a bunch of gcc warnings for the moc test 2021-03-29 15:59:48 +02:00
widgets Mark obsolete QMessageBox members as deprecated 2021-04-23 08:52:01 +02:00
xml tst_qdom: clean-up the code enabled only before Qt 6 2021-01-15 15:22:08 +01:00
CMakeLists.txt CMake: Build minimal subset of tests in desktop static builds 2021-04-06 09:15:37 +01:00
network-settings.h Replace QtTest headers with QTest 2020-12-22 15:20:30 +01:00