You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/07/11 01:39:33 UTC

[47/50] mesos git commit: Windows: Required building with `_UNICODE` and `UNICODE`.

Windows: Required building with `_UNICODE` and `UNICODE`.

Review: https://reviews.apache.org/r/60344/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/33734527
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/33734527
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/33734527

Branch: refs/heads/master
Commit: 33734527c0acd7c577292dfc785f5a48e058acb2
Parents: fcbb67c
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Mon Jul 10 15:51:25 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:39 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/windows.hpp | 32 +++++++++++++++++++--------
 1 file changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/33734527/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows.hpp b/3rdparty/stout/include/stout/windows.hpp
index 6f5b323..92db727 100644
--- a/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/stout/include/stout/windows.hpp
@@ -36,19 +36,33 @@
 #include <glog/logging.h>
 
 
-#ifdef _UNICODE
-// Much of the core Windows API is available both in `string` and `wstring`
+#if !defined(_UNICODE) || !defined(UNICODE)
+// Much of the Windows API is available both in `string` and `wstring`
 // varieties. To avoid polluting the namespace with two versions of every
 // function, a common pattern in the Windows headers is to offer a single macro
 // that expands to the `string` or `wstring` version, depending on whether the
-// `_UNICODE` preprocessor symbol is set. For example, `GetMessage` will expand
-// to either `GetMessageA` (the `string` version) or `GetMessageW` (the
-// `wstring` version) depending on whether this symbol is defined.
+// `_UNICODE` and `UNICODE` preprocessor symbols are set. For example,
+// `GetMessage` will expand to either `GetMessageA` (the `string` version) or
+// `GetMessageW` (the `wstring` version) depending on whether these symbols are
+// defined.
 //
-// The downside of this is that it makes POSIX interop really hard. Hence, we
-// refuse to compile if such a symbol is passed in during compilation.
-#error "Mesos doesn't currently support the `_UNICODE` Windows header constant"
-#endif // _UNICODE
+// Unfortunately the `string` version is not UTF-8, like a developer would
+// expect on Linux, but is instead the current Windows code page, and thus may
+// take a different value at runtime. This makes it potentially difficult to
+// decode, whereas the `wstring` version is always encoded as UTF-16, and thus
+// can be programatically converted to UTF-8 using the `stringify()` function
+// (converting UTF-8 to UTF-16 is done with `wide_stringify()`).
+//
+// Furthermore, support for NTFS long paths requires the use of the `wstring`
+// APIs, coupled with the `\\?\` long path prefix marker for paths longer than
+// the max path limit. This is accomplished by wrapping paths sent to Windows
+// APIs with the `internal::windows::longpath()` helper. In order to prevent
+// future regressions, we enforce the definitions of `_UNICODE` and `UNICODE`.
+//
+// NOTE: The Mesos code should always use the explicit `W` suffixed APIs in
+// order to avoid type ambiguity.
+#error "Mesos must be built with `_UNICODE` and `UNICODE` defined."
+#endif // !defined(_UNICODE) || !defined(UNICODE)
 
 // An RAII `HANDLE`.
 class SharedHandle : public std::shared_ptr<void>