This is an automated email from the ASF dual-hosted git repository.

emmenlau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 034c935  Reduce the usage of Windows.h, and add macros to slim 
Windows.h
     new e66814e  Merge pull request #2450 from 
BioDataAnalysis/bda_slim_windows_h
034c935 is described below

commit 034c9359e978d2465f0ce8530f62c146ef18e935
Author: Mario Emmenlauer <[email protected]>
AuthorDate: Thu May 21 23:04:12 2020 +0200

    Reduce the usage of Windows.h, and add macros to slim Windows.h
---
 lib/cpp/src/thrift/transport/TPipeServer.cpp            | 1 +
 lib/cpp/src/thrift/transport/TPipeServer.h              | 3 ---
 lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h | 1 -
 lib/cpp/src/thrift/windows/Sync.h                       | 6 ++++++
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp 
b/lib/cpp/src/thrift/transport/TPipeServer.cpp
index 1d7577f..e4234b1 100644
--- a/lib/cpp/src/thrift/transport/TPipeServer.cpp
+++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp
@@ -26,6 +26,7 @@
 
 #ifdef _WIN32
 #include <thrift/windows/OverlappedSubmissionThread.h>
+#include <thrift/windows/Sync.h>
 #include <AccCtrl.h>
 #include <Aclapi.h>
 #include <sddl.h>
diff --git a/lib/cpp/src/thrift/transport/TPipeServer.h 
b/lib/cpp/src/thrift/transport/TPipeServer.h
index 67c5d51..249591e 100644
--- a/lib/cpp/src/thrift/transport/TPipeServer.h
+++ b/lib/cpp/src/thrift/transport/TPipeServer.h
@@ -25,9 +25,6 @@
 #ifndef _WIN32
 #include <thrift/transport/TServerSocket.h>
 #endif
-#ifdef _WIN32
-#include <thrift/windows/Sync.h>
-#endif
 
 #define TPIPE_SERVER_MAX_CONNS_DEFAULT PIPE_UNLIMITED_INSTANCES
 
diff --git a/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h 
b/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h
index 6cecfc3..057f623 100644
--- a/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h
+++ b/lib/cpp/src/thrift/windows/OverlappedSubmissionThread.h
@@ -26,7 +26,6 @@
 
 #include <thrift/windows/Sync.h>
 #include <thrift/TNonCopyable.h>
-#include <Windows.h>
 
 /*
   *** Why does this class exist?
diff --git a/lib/cpp/src/thrift/windows/Sync.h 
b/lib/cpp/src/thrift/windows/Sync.h
index b1c83ee..f5b8a05 100644
--- a/lib/cpp/src/thrift/windows/Sync.h
+++ b/lib/cpp/src/thrift/windows/Sync.h
@@ -27,7 +27,13 @@
 #include <thrift/concurrency/Exception.h>
 #include <thrift/TNonCopyable.h>
 
+// Including Windows.h can conflict with Winsock2 usage, and also
+// adds problematic macros like min() and max(). Try to work around:
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
 #include <Windows.h>
+#undef NOMINMAX
+#undef WIN32_LEAN_AND_MEAN
 
 /*
   Lightweight synchronization objects that only make sense on Windows.  For 
cross-platform

Reply via email to