qdatetime.h uses std::min/max and on Windows windows.h (or some subsequent
header file) may under certain circumstances define min/max as macros.
The easiest way to prevent the windows header files from doing that is to
define NOMINMAX in the place right before windows.h is included. The other
way is to define min and max to min/max themselves to prevent windows.h
from doing its evil thing.
If a user of Qt (WebKit in this case) chooses the approach of defining
min/max to themselves and then includes qdatetime.h, then a subsequent
inclusion of windows.h doesn't work because qdatetime.h undefines min/max.
We should not enforce the type of workaround needed, therefore this patch
removes the workaround from qdatetime.h and requires user code that
happens to include windows header files before qdatetime.h (seldom case)
to choose either workaround.
Change-Id: I7347eec7369491a065e894cff557004e069453d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
#include <QtCore/qnamespace.h>
#include <QtCore/qsharedpointer.h>
-// windows.h defines these identifiers, so undefine it
-// ### figure out where in Qt we include it too soon
-#ifdef max
-# undef max
-#endif
-#ifdef min
-# undef min
-#endif
-
#include <limits>
QT_BEGIN_HEADER
**
****************************************************************************/
+// Prevent windows system header files from defining min/max as macros.
+#define NOMINMAX
+
#include <winsock2.h>
#include <ws2tcpip.h>
** $QT_END_LICENSE$
**
****************************************************************************/
+
+#include <qt_windows.h>
+
#include <ocidl.h>
#include <olectl.h>
# define QT_NO_GETADDRINFO
#endif
+// To prevent windows system header files from re-defining min/max
+#define NOMINMAX
+
#if defined(Q_OS_WIN) && !defined(QT_NO_GETADDRINFO)
# include <winsock2.h>
# include <ws2tcpip.h>
****************************************************************************/
#include <qglobal.h>
+// To prevent windows system header files from re-defining min/max
+#define NOMINMAX
#if defined(_WIN32)
#include <winsock2.h>
#else
#include <qglobal.h>
+// To prevent windows system header files from re-defining min/max
+#define NOMINMAX
#if defined(_WIN32)
#include <winsock2.h>
#else
#include <QString>
#ifdef Q_OS_WIN
-# include <windows.h>
+# include <qt_windows.h>
#else
# include <sys/stat.h>
# include <sys/types.h>