diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-07-10 08:16:56 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-07-10 10:41:23 +0200 |
commit | 605062b21fccff919b7894db91b197d120e528f6 (patch) | |
tree | fd9efa198420f25895e87ec199950f436add9a9c /src/corelib | |
parent | f4b5fa76d76a38c8cd97ac410981a2209d100180 (diff) |
Fix MinGW cross-build with precompiled headers on Linux
We need localtime_r() in several places. To have this function
declared when including time.h, _POSIX_THREAD_SAFE_FUNCTIONS must be
defined. E.g. qdatetime.cpp includes unistd.h before time.h to define
said macro.
However, this falls apart when precompiled headers are used, because
of the following include chain in qt_pch.h:
qcoreapplication.h -> qobject.h -> chrono -> time.h
This patch ensures that _POSIX_THREAD_SAFE_FUNCTIONS is defined before
including time.h in qt_pch.h by including unistd.h early.
Fixes: QTBUG-76680
Change-Id: I3875072edf37f45492f29d84fc297a9682e11db4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qt_pch.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/global/qt_pch.h b/src/corelib/global/qt_pch.h index 3972991618..0dfd6c745f 100644 --- a/src/corelib/global/qt_pch.h +++ b/src/corelib/global/qt_pch.h @@ -55,6 +55,10 @@ #include <stdlib.h> #include <qglobal.h> #ifdef Q_OS_WIN +# ifdef Q_CC_MINGW +// <unistd.h> must be included before any other header pulls in <time.h>. +# include <unistd.h> // Define _POSIX_THREAD_SAFE_FUNCTIONS to obtain localtime_r() +# endif # define _POSIX_ # include <limits.h> # undef _POSIX_ |