Bug 928091 - Fix builds for VS2012 and VS2013 to deal with our char16_t machinery; pending r=Waldo
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 18 Oct 2013 18:49:22 -0400
changeset 166158 f5052f28644e3661a3b9812b7ece73fb4e1eeed9
parent 166157 31121f69414d6a5d79c94e21c653018538089213
child 166159 c4f64a12e6ef7bb6ae8fed23290a700081c7aebc
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs928091
milestone27.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 928091 - Fix builds for VS2012 and VS2013 to deal with our char16_t machinery; pending r=Waldo Landing on a CLOSED TREE because this is blocking multiple people. My apologies!
mfbt/Char16.h
--- a/mfbt/Char16.h
+++ b/mfbt/Char16.h
@@ -16,22 +16,33 @@
  * code unit of a Unicode code point, not a "character".
  */
 
 #ifdef _MSC_VER
    /*
     * C++11 says char16_t is a distinct builtin type, but Windows's yvals.h
     * typedefs char16_t as an unsigned short. We would like to alias char16_t
     * to Windows's 16-bit wchar_t so we can declare UTF-16 literals as constant
-    * expressions (and pass char16_t pointers to Windows APIs). We #define our
-    * char16_t as a macro to override yval.h's typedef of the same name.
+    * expressions (and pass char16_t pointers to Windows APIs). We #define
+    * _CHAR16T here in order to prevent yvals.h to override our char16_t
+    * typedefs, which we set to wchar_t for C++ code and to unsigned short for
+    * C code.
+    *
+    * In addition, #defining _CHAR16T will prevent yvals.h from defining a
+    * char32_t type, so we have to undo that damage here and provide our own,
+    * which is identical to the yvals.h type.
     */
 #  define MOZ_UTF16_HELPER(s) L##s
-#  include <yvals.h>
-#  define char16_t wchar_t
+#  define _CHAR16T
+#  ifdef __cplusplus
+     typedef wchar_t char16_t;
+#  else
+     typedef unsigned short char16_t;
+#  endif
+   typedef unsigned int char32_t;
 #elif defined(__cplusplus) && \
       (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
    /* C++11 has a builtin char16_t type. */
 #  define MOZ_UTF16_HELPER(s) u##s
    /**
     * This macro is used to distinguish when char16_t would be a distinct
     * typedef from wchar_t.
     */