aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/plugin.cc
diff options
context:
space:
mode:
authorGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-25 11:52:33 -0700
committerGravatar Jisi Liu <jisi.liu@gmail.com>2017-07-25 11:52:33 -0700
commit759245a49a00315a41b28da8fe52a2894d4f57ea (patch)
tree5a0032a1a3619a448d5301da131907ca8449730f /src/google/protobuf/compiler/plugin.cc
parent4bff88e0fb2338657a781eeee0c5362a57b57bf3 (diff)
Merge from master
Diffstat (limited to 'src/google/protobuf/compiler/plugin.cc')
-rw-r--r--src/google/protobuf/compiler/plugin.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc
index 534b2a73..fcb08551 100644
--- a/src/google/protobuf/compiler/plugin.cc
+++ b/src/google/protobuf/compiler/plugin.cc
@@ -36,18 +36,12 @@
#include <set>
#ifdef _WIN32
-#include <io.h>
#include <fcntl.h>
-#ifndef STDIN_FILENO
-#define STDIN_FILENO 0
-#endif
-#ifndef STDOUT_FILENO
-#define STDOUT_FILENO 1
-#endif
#else
#include <unistd.h>
#endif
+#include <google/protobuf/stubs/io_win32.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/plugin.pb.h>
@@ -55,6 +49,11 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#if defined(_WIN32)
+// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
+// them like we do below.
+using google::protobuf::internal::win32::setmode;
+#endif
namespace google {
namespace protobuf {
@@ -151,8 +150,8 @@ int PluginMain(int argc, char* argv[], const CodeGenerator* generator) {
}
#ifdef _WIN32
- _setmode(STDIN_FILENO, _O_BINARY);
- _setmode(STDOUT_FILENO, _O_BINARY);
+ setmode(STDIN_FILENO, _O_BINARY);
+ setmode(STDOUT_FILENO, _O_BINARY);
#endif
CodeGeneratorRequest request;