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 2015/12/17 23:05:47 UTC

[3/3] mesos git commit: Windows: Replaced global `GetMessage` macro with inline function.

Windows: Replaced global `GetMessage` macro with inline function.

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


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

Branch: refs/heads/master
Commit: ce09c584134e0dbcbebd8b724c88ff6c81fc9247
Parents: 0507368
Author: Alex Clemmer <cl...@gmail.com>
Authored: Wed Dec 16 17:09:48 2015 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Dec 17 13:35:51 2015 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/windows.hpp    | 43 ++++++++++++++++++++
 1 file changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ce09c584/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
index 43c85f5..6711a16 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp
@@ -41,6 +41,49 @@
 //     that uses it (such as Mesos).
 
 
+// This code un-defines the global `GetMessage` macro defined by the Windows
+// headers, and replaces it with an inline function that is equivalent.
+//
+// There are two reasons for doing this. The first is because this macro
+// interferes with `google::protobufs::Reflection::GetMessage`. Replacing the
+// `GetMessage` macro with an inline function allows people calling the
+// `GetMessage` macro to carry on doing so with no code changes, but it will
+// also allow us to use `google::protobufs::Reflection::GetMessage` without
+// interference from the macro.
+//
+// The second is because we don't want to obliterate the `GetMessage` macro for
+// people who include this header, either on purpose, or incidentally as part
+// of some other Mesos header. The effect is that our need to call protobuf's
+// `GetMessage` function has no deleterious effect on customers of this API.
+//
+// NOTE: the Windows headers also don't use define-once semantics for the
+// `GetMessage` macro. In particular, this means that every time you include
+// `Winuser.h` and a `GetMessage` macro isn't defined, the Windows headers will
+// redefine it for you. The impact of this is that you should re-un-define the
+// macro every time you include `Windows.h`; since we should be including
+// `Windows.h` only from this file, we un-define it just after we include
+// `Windows.h`.
+#ifdef GetMessage
+inline BOOL GetMessageWindows(
+    LPMSG lpMsg,
+    HWND hWnd,
+    UINT wMsgFilterMin,
+    UINT wMsgFilterMax)
+{
+  return GetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+}
+#undef GetMessage
+inline BOOL GetMessage(
+    LPMSG lpMsg,
+    HWND hWnd,
+    UINT wMsgFilterMin,
+    UINT wMsgFilterMax)
+{
+  return GetMessageWindows(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+}
+#endif
+
+
 // Define constants used for Windows compat. Allows a lot of code on
 // Windows and POSIX systems to be the same, because we can pass the
 // same constants to functions we call to do things like file I/O.