Bug 836073 - Add MOZ_MSVC_VERSION_AT_LEAST() macro to mfbt/Compiler.h. r=Waldo
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Fri, 20 Jun 2014 09:19:35 -0700
changeset 211149 43a7ce129020b6c34182b6750f521fe5b7f43077
parent 211148 56246d479b89f750abbe4c577687c0640b5875fd
child 211150 85b4fe3a7fa90caa702aa36f6985c667d9e01b02
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs836073
milestone33.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 836073 - Add MOZ_MSVC_VERSION_AT_LEAST() macro to mfbt/Compiler.h. r=Waldo
mfbt/Compiler.h
--- a/mfbt/Compiler.h
+++ b/mfbt/Compiler.h
@@ -4,33 +4,51 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Various compiler checks. */
 
 #ifndef mozilla_Compiler_h
 #define mozilla_Compiler_h
 
+#define MOZ_IS_GCC 0
+#define MOS_IS_MSVC 0
+
 #if !defined(__clang__) && defined(__GNUC__)
 
+#  undef MOZ_IS_GCC
 #  define MOZ_IS_GCC 1
    /*
     * This macro should simplify gcc version checking. For example, to check
     * for gcc 4.5.1 or later, check `#if MOZ_GCC_VERSION_AT_LEAST(4, 5, 1)`.
     */
 #  define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel)          \
      ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \
       >= ((major) * 10000 + (minor) * 100 + (patchlevel)))
 #  if !MOZ_GCC_VERSION_AT_LEAST(4, 4, 0)
 #    error "mfbt (and Gecko) require at least gcc 4.4 to build."
 #  endif
 
-#else
+#elif defined(_MSC_VER)
 
-#  define MOZ_IS_GCC 0
+#  undef MOZ_IS_MSVC
+#  define MOZ_IS_MSVC 1
+   /*
+    * This macro should simplify MSVC version checking. For example, to check
+    * for VC10 or later, check `#ifdef MOZ_MSVC_VERSION_AT_LEAST(10)`.
+    */
+#  define MOZ_MSVC_VERSION_AT_LEAST(version) \
+     (version == 10 ? _MSC_VER >= 1600 : \
+     (version == 11 ? _MSC_VER >= 1700 : \
+     (version == 12 ? _MSC_VER >= 1800 : \
+     (version == 13 ? _MSC_VER >= 1900 : \
+      0))))
+#  if !MOZ_MSVC_VERSION_AT_LEAST(10)
+#    error "mfbt (and Gecko) require at least MSVC 2010 RTM to build."
+#  endif
 
 #endif
 
 /*
  * The situation with standard libraries is a lot worse than with compilers,
  * particularly as clang and gcc could end up using one of three or so standard
  * libraries, and they may not be up-to-snuff with newer C++11 versions. To
  * detect the library, we're going to include cstddef (which is a small header