Pārlūkot izejas kodu

Fix issues with Windows build: Always use ASCII version of CreateProcess (even if UNICODE is defined) and move GetMessage macro work-around to common.h so that it covers extension_set.h as well. Patch from Nick Carter.

kenton@google.com 15 gadi atpakaļ
vecāks
revīzija
529a843f2d

+ 11 - 11
src/google/protobuf/compiler/subprocess.cc

@@ -96,7 +96,7 @@ void Subprocess::Start(const string& program, SearchMode search_mode) {
   }
   }
 
 
   // Setup STARTUPINFO to redirect handles.
   // Setup STARTUPINFO to redirect handles.
-  STARTUPINFO startup_info;
+  STARTUPINFOA startup_info;
   ZeroMemory(&startup_info, sizeof(startup_info));
   ZeroMemory(&startup_info, sizeof(startup_info));
   startup_info.cb = sizeof(startup_info);
   startup_info.cb = sizeof(startup_info);
   startup_info.dwFlags = STARTF_USESTDHANDLES;
   startup_info.dwFlags = STARTF_USESTDHANDLES;
@@ -115,16 +115,16 @@ void Subprocess::Start(const string& program, SearchMode search_mode) {
   // Create the process.
   // Create the process.
   PROCESS_INFORMATION process_info;
   PROCESS_INFORMATION process_info;
 
 
-  if (CreateProcess((search_mode == SEARCH_PATH) ? NULL : program.c_str(),
-                    (search_mode == SEARCH_PATH) ? name_copy : NULL,
-                    NULL,  // process security attributes
-                    NULL,  // thread security attributes
-                    TRUE,  // inherit handles?
-                    0,     // obscure creation flags
-                    NULL,  // environment (inherit from parent)
-                    NULL,  // current directory (inherit from parent)
-                    &startup_info,
-                    &process_info)) {
+  if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(),
+                     (search_mode == SEARCH_PATH) ? name_copy : NULL,
+                     NULL,  // process security attributes
+                     NULL,  // thread security attributes
+                     TRUE,  // inherit handles?
+                     0,     // obscure creation flags
+                     NULL,  // environment (inherit from parent)
+                     NULL,  // current directory (inherit from parent)
+                     &startup_info,
+                     &process_info)) {
     child_handle_ = process_info.hProcess;
     child_handle_ = process_info.hProcess;
     CloseHandleOrDie(process_info.hThread);
     CloseHandleOrDie(process_info.hThread);
     child_stdin_ = stdin_pipe_write;
     child_stdin_ = stdin_pipe_write;

+ 0 - 19
src/google/protobuf/message.h

@@ -123,25 +123,6 @@
 
 
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/common.h>
 
 
-#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
-
-
 namespace google {
 namespace google {
 namespace protobuf {
 namespace protobuf {
 
 

+ 18 - 0
src/google/protobuf/stubs/common.h

@@ -48,6 +48,24 @@
 #include <stdint.h>
 #include <stdint.h>
 #endif
 #endif
 
 
+#if defined(_WIN32) && defined(GetMessage)
+// Allow GetMessage to be used as a valid method name in protobuf classes.
+// windows.h defines GetMessage() as a macro.  Let's re-define it as an inline
+// function.  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
+
+
 namespace std {}
 namespace std {}
 
 
 namespace google {
 namespace google {