Bug 88313 - [Qt][Win] Fix build fails because of min/max macros and std::numeric_limits<*>::min/max() clashing
Summary: [Qt][Win] Fix build fails because of min/max macros and std::numeric_limits<*...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 420+
Hardware: All All
: P1 Blocker
Assignee: Csaba Osztrogonác
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks: 88300
  Show dependency treegraph
 
Reported: 2012-06-05 01:37 PDT by Csaba Osztrogonác
Modified: 2012-06-13 08:18 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.18 KB, patch)
2012-06-05 08:53 PDT, Csaba Osztrogonác
no flags Details | Formatted Diff | Diff
Patch (1.19 KB, patch)
2012-06-05 09:07 PDT, Csaba Osztrogonác
no flags Details | Formatted Diff | Diff
Patch (3.39 KB, patch)
2012-06-07 09:08 PDT, Csaba Osztrogonác
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Csaba Osztrogonác 2012-06-05 01:37:56 PDT
qwebframe.cpp, ... doesn't build because of this problem.
Comment 1 Csaba Osztrogonác 2012-06-05 08:53:48 PDT
Created attachment 145809 [details]
Patch
Comment 2 Csaba Osztrogonác 2012-06-05 09:07:08 PDT
Created attachment 145813 [details]
Patch

Typo fixed. Thanks GTK EWS. :)
Comment 3 Simon Hausmann 2012-06-05 14:22:32 PDT
Comment on attachment 145813 [details]
Patch

This is like a sledge-hammer :). Is it perhaps cleaner to do NOMINMAX only in those .cpp files where the clash occurs? That seems to be the more common solution and I think preferred if for example it only happens in qwebframe.cpp.
Comment 4 Csaba Osztrogonác 2012-06-07 05:29:34 PDT
(In reply to comment #3)
> (From update of attachment 145813 [details])
> This is like a sledge-hammer :). Is it perhaps cleaner to do NOMINMAX only in those .cpp files where the clash occurs? That seems to be the more common solution and I think preferred if for example it only happens in qwebframe.cpp.

:) As far as I remember we need this for 5-10 files not only one.
Let me check how many files need it.
Comment 5 Csaba Osztrogonác 2012-06-07 08:52:28 PDT
problematic source files:
- Source/WebKit/qt/Api/qwebview.cpp
- Source/WebKit/qt/Api/gqraphicswebview.cpp
- Source/WebKit/qt/Api/qwebpage.cpp
- Source/WebKit/qt/Api/qwebhistory.cpp
- Source/WebKit/qt/WebCoreSupport/GeolocationClientQt.cpp

Patch is coming soon.
Comment 6 Csaba Osztrogonác 2012-06-07 09:08:17 PDT
Created attachment 146300 [details]
Patch

Add NOMINMAX only to problematic sources instead of using sledgehammer :)
Comment 7 Balazs Kelemen 2012-06-08 08:45:35 PDT
(In reply to comment #6)
> Created an attachment (id=146300) [details]
> Patch
> 
> Add NOMINMAX only to problematic sources instead of using sledgehammer :)

In most parts of the project we already use the sledgehammer approach.
In config.h's you can find this - under #if OS(WINDOWS)

// If we don't define these, they get defined in windef.h.
// We want to use std::min and std::max.
#ifndef max
#define max max
#endif
#ifndef min
#define min min
#endif

What I don't know is that which config.h is used in Source/WebKit/qt and why it does not have this. Furthermore, adding NOMINMAX seems more elegant than this ifdef hackery but I'm not sure it would work on every platform. I favor fixing it in the appropriate config.h for consistency.
Comment 8 Jocelyn Turcotte 2012-06-11 12:13:51 PDT
WebCore/config.h is used by WebKit/qt.

We "#define max max" correctly in config.h but the problem is that qdatetime.h does "#undef max" before WinDef.h gets included.

How the hell did this end up in a public Qt header...
Comment 9 Simon Hausmann 2012-06-11 12:22:53 PDT
(In reply to comment #8)
> WebCore/config.h is used by WebKit/qt.
> 
> We "#define max max" correctly in config.h but the problem is that qdatetime.h does "#undef max" before WinDef.h gets included.
> 
> How the hell did this end up in a public Qt header...

Well spotted!! And pretty recently changed, too:

https://codereview.qt-project.org/#change,13166

The header file uses std::min/max in an inline function, but yeah, the fix is there IMHO.
Comment 10 Simon Hausmann 2012-06-12 01:19:31 PDT
Work in progress at https://codereview.qt-project.org/#change,28549 - If we can't get that into Qt, then we have to change the existing workaround in WebKit to use NOMINMAX instead of #define min min/max max
Comment 11 Csaba Osztrogonác 2012-06-12 06:25:05 PDT
(In reply to comment #10)
> Work in progress at https://codereview.qt-project.org/#change,28549 - If we can't get that into Qt, then we have to change the existing workaround in WebKit to use NOMINMAX instead of #define min min/max max

I tried it, it works for me without workaround for WebKit. ;-)
Comment 12 Simon Hausmann 2012-06-13 08:17:47 PDT
(In reply to comment #11)
> (In reply to comment #10)
> > Work in progress at https://codereview.qt-project.org/#change,28549 - If we can't get that into Qt, then we have to change the existing workaround in WebKit to use NOMINMAX instead of #define min min/max max
> 
> I tried it, it works for me without workaround for WebKit. ;-)

Great. The change is slowly making its way into Qt. Most of the submodules are patched already and the qtbase change is staged (after the n-th try :)

Let's close this as INVALID then, because the root cause for this bug is an upstream issue that disabled the existing workaround.
Comment 13 Simon Hausmann 2012-06-13 08:18:17 PDT
Comment on attachment 146300 [details]
Patch

Clearing review