path: root/src
diff options
authorMarc Mutz <>2013-11-05 18:45:44 +0100
committerThe Qt Project <>2013-11-06 09:35:01 +0100
commit6d45bf683e17092059a553fd31ad2a89672e3195 (patch)
tree38ef0083d6ef7654201f2e47fd9fda944f4b9f2f /src
parent6381c807e550fa6f1f7425dc800dbf8be121ab82 (diff)
QGlobal: static_assert that sizeof(int) == 4 and UCHAR_MAX == 255
According to Thiago, Qt assumes this in a lot of places, so make it explicit. Change-Id: I3f4a55699379fd9fe4d792061c80b3b589c10c53 Reviewed-by: Olivier Goffart <> Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src')
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index ca780346bc..a874b231cc 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -88,6 +88,14 @@ Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
+// Statically check assumptions about the environment we're running
+// in. The idea here is to error or warn if otherwise implicit Qt
+// assumptions are not fulfilled on new hardware or compilers
+// (if this list becomes too long, consider factoring into a separate file)
+Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits");
+Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
\class QFlag
\inmodule QtCore