From 709ea28f3264aa5632e5577a4080671173fc6166 Mon Sep 17 00:00:00 2001 From: "kenton@google.com" Date: Wed, 22 Apr 2009 20:06:20 +0000 Subject: Work around windows.h #defining GetMessage(). --- src/google/protobuf/message.h | 18 ++++++++++++++++++ src/google/protobuf/test_util.cc | 6 ++++++ src/google/protobuf/testing/googletest.h | 1 + 3 files changed, 25 insertions(+) (limited to 'src/google') diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 0674a12c..b4209026 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -117,6 +117,24 @@ #else #include #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 diff --git a/src/google/protobuf/test_util.cc b/src/google/protobuf/test_util.cc index c1e9fa78..60413f6d 100644 --- a/src/google/protobuf/test_util.cc +++ b/src/google/protobuf/test_util.cc @@ -32,6 +32,12 @@ // 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 +#endif + #include #include #include diff --git a/src/google/protobuf/testing/googletest.h b/src/google/protobuf/testing/googletest.h index 0cb139cd..71444c96 100644 --- a/src/google/protobuf/testing/googletest.h +++ b/src/google/protobuf/testing/googletest.h @@ -58,6 +58,7 @@ string GetCapturedTestStderr(); // 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: -- cgit v1.2.3