Bug 73563

Summary: use NOMINMAX instead of #define min min
Product: WebKit Reporter: Paul <harris.pc>
Component: JavaScriptCoreAssignee: Patrick R. Gansterer <paroga>
Status: RESOLVED FIXED    
Severity: Normal CC: aroben, bfulgham, dglazkov, hausmann, jchaffraix, jedrzej.nowacki, paroga, webkit-ews, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows 7   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Paul 2011-12-01 07:45:09 PST
This is a patch from my code.  I'm working with QT 4.7.4,
but I've checked webkit's code on the trunk via trac's Source Browse and I see the problem still exists.

Instead of using #define min min and #define max max, to avoid problems with windef.h
just use #define NOMINMAX

This is actually what is done in wtf/Platform.h although I think that only applies for WINCE.



=== modified file 'qt/src/3rdparty/javascriptcore/JavaScriptCore/config.h'
--- qt/src/3rdparty/javascriptcore/JavaScriptCore/config.h      2011-10-08 14:07:42 +0000
+++ qt/src/3rdparty/javascriptcore/JavaScriptCore/config.h      2011-12-01 15:14:46 +0000
@@ -41,8 +41,7 @@
 
 // If we don't define these, they get defined in windef.h. 
 // We want to use std::min and std::max
-#define max max
-#define min min
+#define NOMINMAX       /* Windows min and max conflict with standard macros */
 
 #if !COMPILER(MSVC7) && !OS(WINCE)
 // We need to define this before the first #include of stdlib.h or it won't contain rand_s.
Comment 1 Alexey Proskuryakov 2011-12-01 11:51:11 PST
Would you be willing to submit a patch, as described in <http://www.webkit.org/coding/contributing.html>?

Please correct the comment above, too.
Comment 2 Paul 2011-12-04 18:01:59 PST
Created attachment 117817 [details]
Patch
Comment 3 Paul 2011-12-04 18:05:44 PST
Uploaded patch that adjusts 5 header files to declare NOMINMAX instead of using the trick #define min min
This is the more correct way of dealing with windef.h's #define min/max issue on the windows platform.

I have not tested it, as I am not set up to build Webkit, sorry.  If I need to make more significant changes in the future then I'll go through that process.


Also, I'm not sure how to edit previously made comments.
Comment 4 WebKit Review Bot 2011-12-04 20:00:05 PST
Comment on attachment 117817 [details]
Patch

Attachment 117817 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10729611

New failing tests:
svg/custom/linking-uri-01-b.svg
Comment 5 Paul 2011-12-04 20:06:49 PST
I don't see how my patch could've generated an image mismatch in the test suite,

I can only assume it was broken before the patch was applied... can that be the case?
Comment 6 Julien Chaffraix 2011-12-05 17:00:54 PST
> I can only assume it was broken before the patch was applied... can that be the case?

It's a flaky test (cf webkit-dev) and is likely not your wrong doing.
Comment 7 Adam Roben (:aroben) 2011-12-06 06:36:24 PST
Comment on attachment 117817 [details]
Patch

I agree this is better than #define min min!

I think an even better way to do this these days would be to put this in WebKitLibraries/win/tools/vsprops/common.vsprops. All projects inherit settings from there.
Comment 8 Patrick R. Gansterer 2013-09-20 14:30:11 PDT
Created attachment 212218 [details]
Patch
Comment 9 Early Warning System Bot 2013-09-20 14:44:50 PDT
Comment on attachment 212218 [details]
Patch

Attachment 212218 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/2034010
Comment 10 Early Warning System Bot 2013-09-20 14:47:57 PDT
Comment on attachment 212218 [details]
Patch

Attachment 212218 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/2031013
Comment 11 Patrick R. Gansterer 2013-09-20 14:50:07 PDT
Created attachment 212221 [details]
Patch
Comment 12 Brent Fulgham 2013-09-23 15:09:03 PDT
Comment on attachment 212221 [details]
Patch

This looks good.  I wish the EWS had been working when you filed the bug, but I don't see any obvious reason for this to fail.

Let's land it and I'll roll it out if there is any build problem.
Comment 13 Patrick R. Gansterer 2013-09-23 15:24:36 PDT
Comment on attachment 212221 [details]
Patch

Clearing flags on attachment: 212221

Committed r156302: <http://trac.webkit.org/changeset/156302>
Comment 14 Patrick R. Gansterer 2013-09-23 15:24:43 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 Patrick R. Gansterer 2013-10-30 15:17:19 PDT
*** Bug 109161 has been marked as a duplicate of this bug. ***