Bug 786533 - On Windows, one of the system header files (windef.h) defines 'min' and 'max' as macros which breaks any use of std::min/std::max. Define NOMINMAX before including system header files where needed to avoid defining those macros. r=ehsan
authorMats Palmgren <matspal@gmail.com>
Tue, 15 Jan 2013 13:22:03 +0100
changeset 128759 b59c92bc4059a07c71c05a01f6009175cb621f0f
parent 128758 04fb583963dc5f696bdb997a1a21f8a5fa198f47
child 128760 c26871bd5f5effec8546dd48f77be3434c800f1e
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs786533
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 786533 - On Windows, one of the system header files (windef.h) defines 'min' and 'max' as macros which breaks any use of std::min/std::max. Define NOMINMAX before including system header files where needed to avoid defining those macros. r=ehsan
accessible/src/windows/ia2/Makefile.in
accessible/src/windows/sdn/Makefile.in
accessible/src/windows/uia/Makefile.in
config/gcc-stl-wrapper.template.h
config/msvc-stl-wrapper.template.h
content/media/webrtc/Makefile.in
content/media/wmf/Makefile.in
embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
--- a/accessible/src/windows/ia2/Makefile.in
+++ b/accessible/src/windows/ia2/Makefile.in
@@ -34,16 +34,20 @@ EXPORTS = \
   ia2AccessibleAction.h \
   ia2AccessibleComponent.h \
   ia2AccessibleEditableText.h \
   ia2AccessibleHyperlink.h \
   ia2AccessibleHypertext.h \
   ia2AccessibleText.h \
   $(NULL)
 
+# The midl generated code include Windows headers which defines min and max
+# macros which conflicts with std::min/max.  Suppress the macros:
+OS_CXXFLAGS += -DNOMINMAX
+
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
   -I$(srcdir) \
--- a/accessible/src/windows/sdn/Makefile.in
+++ b/accessible/src/windows/sdn/Makefile.in
@@ -8,16 +8,19 @@ srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = accessibility
 LIBRARY_NAME = accessibility_toolkit_sdn_s
 EXPORT_LIBRARY = 1
 LIBXUL_LIBRARY = 1
+# The midl generated code include Windows headers which defines min and max
+# macros which conflicts with std::min/max.  Suppress the macros:
+OS_CXXFLAGS += -DNOMINMAX
 
 CPPSRCS += \
   sdnAccessible.cpp \
   $(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
--- a/accessible/src/windows/uia/Makefile.in
+++ b/accessible/src/windows/uia/Makefile.in
@@ -8,16 +8,19 @@ srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = accessibility
 LIBRARY_NAME = accessibility_toolkit_uia_s
 EXPORT_LIBRARY = ..
 LIBXUL_LIBRARY = 1
+# The midl generated code include Windows headers which defines min and max
+# macros which conflicts with std::min/max.  Suppress the macros:
+OS_CXXFLAGS += -DNOMINMAX
 
 
 CPPSRCS += \
   uiaRawElmProvider.cpp \
   $(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
--- a/config/gcc-stl-wrapper.template.h
+++ b/config/gcc-stl-wrapper.template.h
@@ -12,16 +12,21 @@
 // compiling ObjC.
 #if __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS)
 #  error "STL code can only be used with -fno-exceptions"
 #endif
 
 // Silence "warning: #include_next is a GCC extension"
 #pragma GCC system_header
 
+#ifdef _WIN32
+// Suppress windef.h min and max macros - they make std::min/max not compile.
+#define NOMINMAX 1
+#endif
+
 // mozalloc.h wants <new>; break the cycle by always explicitly
 // including <new> here.  NB: this is a tad sneaky.  Sez the gcc docs:
 //
 //    `#include_next' does not distinguish between <file> and "file"
 //    inclusion, nor does it check that the file you specify has the
 //    same name as the current file. It simply looks for the file
 //    named, starting with the directory in the search path after the
 //    one where the current file was found.
--- a/config/msvc-stl-wrapper.template.h
+++ b/config/msvc-stl-wrapper.template.h
@@ -7,16 +7,19 @@
 
 #ifndef mozilla_${HEADER}_h
 #define mozilla_${HEADER}_h
 
 #if _HAS_EXCEPTIONS
 #  error "STL code can only be used with -fno-exceptions"
 #endif
 
+// Suppress windef.h min and max macros - they make std::min/max not compile.
+#define NOMINMAX 1
+
 // Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
 // CRT doesn't export std::_Throw().  So we define it.
 #ifndef mozilla_Throw_h
 #  include "mozilla/throw_msvc.h"
 #endif
 
 // Code might include <new> before other wrapped headers, but <new>
 // includes <exception> and so we want to wrap it.  But mozalloc.h
--- a/content/media/webrtc/Makefile.in
+++ b/content/media/webrtc/Makefile.in
@@ -29,16 +29,20 @@ EXPORTS += \
 
 CPPSRCS += \
   MediaEngineWebRTC.cpp \
   MediaEngineWebRTCVideo.cpp \
   MediaEngineWebRTCAudio.cpp \
   $(NULL)
 endif
 
+ifeq ($(OS_ARCH),WINNT)
+OS_CXXFLAGS += -DNOMINMAX
+endif
+
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_WEBRTC
 LOCAL_INCLUDES += \
   -I$(topsrcdir)/media/webrtc/trunk/src \
   -I$(topsrcdir)/media/webrtc/signaling/src/common \
--- a/content/media/wmf/Makefile.in
+++ b/content/media/wmf/Makefile.in
@@ -20,11 +20,15 @@ EXPORTS		+= \
 
 CPPSRCS		= \
 		WMFByteStream.cpp \
 		WMFDecoder.cpp \
 		WMFReader.cpp \
 		WMFUtils.cpp \
 		$(NULL)
 
+ifeq ($(OS_ARCH),WINNT)
+OS_CXXFLAGS += -DNOMINMAX
+endif
+
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
--- a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
+++ b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
@@ -15,16 +15,18 @@ To Build This:
 
 WIN_LIBS=                                       \
         winspool.lib                           \
         comctl32.lib                           \
         comdlg32.lib
 
 ---------------------------------------------------------------------- */
 
+#define NOMINMAX 1
+
 #include "plstr.h"
 #include <windows.h>
 #include <tchar.h>
 
 #include <unknwn.h>
 #include <commdlg.h>
 
 #include "nsIWebBrowserPrint.h"
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG
 #endif
 
-#include <stdarg.h>
+#include <cstdarg>
 
 #include "prlog.h"
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 #ifdef XP_WIN
 #include <windows.h>
 #endif