From 6d45bf683e17092059a553fd31ad2a89672e3195 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Nov 2013 18:45:44 +0100 Subject: 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 --- src/corelib/global/qglobal.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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); #endif +// 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 -- cgit v1.2.3