Commits

Anonymous committed 6d17a8c

Work around windows.h #defining GetMessage().

Comments (0)

Files changed (3)

src/google/protobuf/message.h

 #else
 #include <iosfwd>
 #endif
+
+#if defined(_WIN32) && defined(GetMessage)
+// windows.h defines GetMessage() as a macro.  Let's re-define it as an inline
+// function.  This is necessary because Reflection has a method called
+// GetMessage() which we don't want overridden.  The inline function should be
+// equivalent for C++ users.
+inline BOOL GetMessage_Win32(
+    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 GetMessage_Win32(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
+}
+#endif
 
 #include <google/protobuf/stubs/common.h>
 

src/google/protobuf/test_util.cc

 //  Based on original Protocol Buffers design by
 //  Sanjay Ghemawat, Jeff Dean, and others.
 
+#ifdef _WIN32
+// Verify that #icnluding windows.h does not break anything (e.g. because
+// windows.h #defines GetMessage() as a macro).
+#include <windows.h>
+#endif
+
 #include <google/protobuf/test_util.h>
 #include <google/protobuf/descriptor.h>
 #include <google/protobuf/message.h>

src/google/protobuf/testing/googletest.h

 // For use with ScopedMemoryLog::GetMessages().  Inside Google the LogLevel
 // constants don't have the LOGLEVEL_ prefix, so the code that used
 // ScopedMemoryLog refers to LOGLEVEL_ERROR as just ERROR.
+#undef ERROR  // defend against promiscuous windows.h
 static const LogLevel ERROR = LOGLEVEL_ERROR;
 
 // Receives copies of all LOG(ERROR) messages while in scope.  Sample usage:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.