Fixed type integers: streamline the definitions

On all the platforms we support, we require these sizes in bits:

* char: 8
* short: 16
* int: 32
* long long: 64

We can get rid of the MSVC-specific type aliases (MSVC guarantees
__intXX to be aliases anyhow, not extended integer types) and just
use the builtin types.

Also, we require C++11 and C99, so "LL" and "ULL" are the correct
standard suffixes for (unsigned) long long. Remove the non-standard
suffixes from the Q_(U)INT64_C macros.

Change-Id: If007cd88d74064a163b5e910ca1983acd1dd1d10
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2021-04-23 11:49:34 +02:00
parent 7d92ef63d7
commit 49609f58a5
2 changed files with 6 additions and 12 deletions

View File

@ -786,8 +786,8 @@ static_assert(sizeof(qint64) == 8, "Internal error, qint64 is misdefined");
/*! \typedef qint64 /*! \typedef qint64
\relates <QtGlobal> \relates <QtGlobal>
Typedef for \c{long long int} (\c __int64 on Windows). This type Typedef for \c{long long int}. This type is guaranteed to be 64-bit
is guaranteed to be 64-bit on all platforms supported by Qt. on all platforms supported by Qt.
Literals of this type can be created using the Q_INT64_C() macro: Literals of this type can be created using the Q_INT64_C() macro:
@ -800,9 +800,8 @@ static_assert(sizeof(qint64) == 8, "Internal error, qint64 is misdefined");
\typedef quint64 \typedef quint64
\relates <QtGlobal> \relates <QtGlobal>
Typedef for \c{unsigned long long int} (\c{unsigned __int64} on Typedef for \c{unsigned long long int}. This type is guaranteed to
Windows). This type is guaranteed to be 64-bit on all platforms be 64-bit on all platforms supported by Qt.
supported by Qt.
Literals of this type can be created using the Q_UINT64_C() Literals of this type can be created using the Q_UINT64_C()
macro: macro:

View File

@ -226,12 +226,8 @@ typedef short qint16; /* 16 bit signed */
typedef unsigned short quint16; /* 16 bit unsigned */ typedef unsigned short quint16; /* 16 bit unsigned */
typedef int qint32; /* 32 bit signed */ typedef int qint32; /* 32 bit signed */
typedef unsigned int quint32; /* 32 bit unsigned */ typedef unsigned int quint32; /* 32 bit unsigned */
#if defined(Q_OS_WIN) && !defined(Q_CC_GNU) // Unlike LL / ULL in C++, for historical reasons, we force the
# define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */ // result to be of the requested type.
# define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */
typedef __int64 qint64; /* 64 bit signed */
typedef unsigned __int64 quint64; /* 64 bit unsigned */
#else
#ifdef __cplusplus #ifdef __cplusplus
# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */ # define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */
# define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */ # define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */
@ -241,7 +237,6 @@ typedef unsigned __int64 quint64; /* 64 bit unsigned */
#endif #endif
typedef long long qint64; /* 64 bit signed */ typedef long long qint64; /* 64 bit signed */
typedef unsigned long long quint64; /* 64 bit unsigned */ typedef unsigned long long quint64; /* 64 bit unsigned */
#endif
typedef qint64 qlonglong; typedef qint64 qlonglong;
typedef quint64 qulonglong; typedef quint64 qulonglong;