THRIFT-1031 Patch to compile Thrift for vc++ 9.0 and 10.0
=> some more improvements
Patch: James Dickson
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1174801 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/compiler.sln b/compiler/cpp/compiler.sln
new file mode 100644
index 0000000..94961aa
--- /dev/null
+++ b/compiler/cpp/compiler.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compiler", "compiler.vcxproj", "{89975A1A-F799-4556-98B8-64E30AB39A90}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {89975A1A-F799-4556-98B8-64E30AB39A90}.Debug|Win32.ActiveCfg = Debug|Win32
+ {89975A1A-F799-4556-98B8-64E30AB39A90}.Debug|Win32.Build.0 = Debug|Win32
+ {89975A1A-F799-4556-98B8-64E30AB39A90}.Release|Win32.ActiveCfg = Release|Win32
+ {89975A1A-F799-4556-98B8-64E30AB39A90}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/compiler/cpp/compiler.vcxproj b/compiler/cpp/compiler.vcxproj
new file mode 100644
index 0000000..5f43577
--- /dev/null
+++ b/compiler/cpp/compiler.vcxproj
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\generate\t_generator.h" />
+ <ClInclude Include="src\generate\t_generator_registry.h" />
+ <ClInclude Include="src\generate\t_oop_generator.h" />
+ <ClInclude Include="src\globals.h" />
+ <ClInclude Include="src\main.h" />
+ <ClInclude Include="src\md5.h" />
+ <ClInclude Include="src\parse\t_base_type.h" />
+ <ClInclude Include="src\parse\t_const.h" />
+ <ClInclude Include="src\parse\t_const_value.h" />
+ <ClInclude Include="src\parse\t_container.h" />
+ <ClInclude Include="src\parse\t_doc.h" />
+ <ClInclude Include="src\parse\t_enum.h" />
+ <ClInclude Include="src\parse\t_enum_value.h" />
+ <ClInclude Include="src\parse\t_field.h" />
+ <ClInclude Include="src\parse\t_function.h" />
+ <ClInclude Include="src\parse\t_list.h" />
+ <ClInclude Include="src\parse\t_map.h" />
+ <ClInclude Include="src\parse\t_program.h" />
+ <ClInclude Include="src\parse\t_scope.h" />
+ <ClInclude Include="src\parse\t_service.h" />
+ <ClInclude Include="src\parse\t_set.h" />
+ <ClInclude Include="src\parse\t_struct.h" />
+ <ClInclude Include="src\parse\t_type.h" />
+ <ClInclude Include="src\parse\t_typedef.h" />
+ <ClInclude Include="src\platform.h" />
+ <ClInclude Include="src\thrifty.h" />
+ <ClInclude Include="src\windows\config.h" />
+ <ClInclude Include="src\windows\version.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\generate\t_as3_generator.cc" />
+ <ClCompile Include="src\generate\t_cocoa_generator.cc" />
+ <ClCompile Include="src\generate\t_cpp_generator.cc" />
+ <ClCompile Include="src\generate\t_csharp_generator.cc" />
+ <ClCompile Include="src\generate\t_c_glib_generator.cc" />
+ <ClCompile Include="src\generate\t_erl_generator.cc" />
+ <ClCompile Include="src\generate\t_generator.cc" />
+ <ClCompile Include="src\generate\t_go_generator.cc" />
+ <ClCompile Include="src\generate\t_hs_generator.cc" />
+ <ClCompile Include="src\generate\t_html_generator.cc" />
+ <ClCompile Include="src\generate\t_javame_generator.cc" />
+ <ClCompile Include="src\generate\t_java_generator.cc" />
+ <ClCompile Include="src\generate\t_js_generator.cc" />
+ <ClCompile Include="src\generate\t_ocaml_generator.cc" />
+ <ClCompile Include="src\generate\t_perl_generator.cc" />
+ <ClCompile Include="src\generate\t_php_generator.cc" />
+ <ClCompile Include="src\generate\t_py_generator.cc" />
+ <ClCompile Include="src\generate\t_rb_generator.cc" />
+ <ClCompile Include="src\generate\t_st_generator.cc" />
+ <ClCompile Include="src\generate\t_xsd_generator.cc" />
+ <ClCompile Include="src\main.cc" />
+ <ClCompile Include="src\md5.c" />
+ <ClCompile Include="src\parse\parse.cc" />
+ <ClCompile Include="src\thriftl.cc" />
+ <ClCompile Include="src\thrifty.cc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="README_WINDOWS" />
+ <None Include="src\thriftl.ll" />
+ <None Include="src\thrifty.yy" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{89975A1A-F799-4556-98B8-64E30AB39A90}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>compiler</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IncludePath>$(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
+ <TargetName>thrift</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IncludePath>$(ProjectDir)\src\;$(ProjectDir)\src\windows\;$(IncludePath)</IncludePath>
+ <TargetName>thrift</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;MINGW;YY_NO_UNISTD_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ForcedIncludeFiles>config.h</ForcedIncludeFiles>
+ <CompileAs>CompileAsCpp</CompileAs>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ <PreBuildEvent>
+ <Command>flex -o "src/thriftl.cc" src/thriftl.ll
+bison -y -o "src/thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;MINGW;YY_NO_UNISTD_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ForcedIncludeFiles>config.h</ForcedIncludeFiles>
+ <CompileAs>CompileAsCpp</CompileAs>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ <PreBuildEvent>
+ <Command>flex -o "src/thriftl.cc" src/thriftl.ll
+bison -y -o "src/thrifty.cc" --defines="src/thrifty.h" src/thrifty.yy</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/compiler/cpp/compiler.vcxproj.filters b/compiler/cpp/compiler.vcxproj.filters
new file mode 100644
index 0000000..16a690f
--- /dev/null
+++ b/compiler/cpp/compiler.vcxproj.filters
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClInclude Include="src\main.h" />
+ <ClInclude Include="src\windows\version.h">
+ <Filter>windows</Filter>
+ </ClInclude>
+ <ClInclude Include="src\windows\config.h">
+ <Filter>windows</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_base_type.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_const.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_const_value.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_container.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_doc.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_enum.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_enum_value.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_field.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_function.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_list.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_map.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_program.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_scope.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_service.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_set.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_struct.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_type.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\parse\t_typedef.h">
+ <Filter>parse</Filter>
+ </ClInclude>
+ <ClInclude Include="src\generate\t_generator.h">
+ <Filter>generate</Filter>
+ </ClInclude>
+ <ClInclude Include="src\generate\t_generator_registry.h">
+ <Filter>generate</Filter>
+ </ClInclude>
+ <ClInclude Include="src\generate\t_oop_generator.h">
+ <Filter>generate</Filter>
+ </ClInclude>
+ <ClInclude Include="src\globals.h" />
+ <ClInclude Include="src\md5.h" />
+ <ClInclude Include="src\platform.h" />
+ <ClInclude Include="src\thrifty.h">
+ <Filter>generated</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="windows">
+ <UniqueIdentifier>{ae9d0a15-57ae-4f01-87a4-81f790249b83}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="resources">
+ <UniqueIdentifier>{c9be9380-57bb-438a-a647-4a6943326d6b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="generated">
+ <UniqueIdentifier>{79697fe7-fdf0-4ed4-bb4f-3128632c3446}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="parse">
+ <UniqueIdentifier>{5df016bb-591b-420a-a535-4330d9187fbf}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="generate">
+ <UniqueIdentifier>{b5c626af-afa5-433c-8e10-ee734533cb68}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\main.cc" />
+ <ClCompile Include="src\parse\parse.cc">
+ <Filter>parse</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_as3_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_c_glib_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_cocoa_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_cpp_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_csharp_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_erl_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_hs_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_html_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_java_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_javame_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_js_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_ocaml_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_perl_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_php_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_rb_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_st_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_xsd_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\md5.c" />
+ <ClCompile Include="src\thriftl.cc">
+ <Filter>generated</Filter>
+ </ClCompile>
+ <ClCompile Include="src\thrifty.cc">
+ <Filter>generated</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_go_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ <ClCompile Include="src\generate\t_py_generator.cc">
+ <Filter>generate</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="src\thriftl.ll">
+ <Filter>resources</Filter>
+ </None>
+ <None Include="src\thrifty.yy">
+ <Filter>resources</Filter>
+ </None>
+ <None Include="README_WINDOWS" />
+ </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/lib/cpp/libthrift.vcxproj b/lib/cpp/libthrift.vcxproj
index 0e4c942..5896726 100644
--- a/lib/cpp/libthrift.vcxproj
+++ b/lib/cpp/libthrift.vcxproj
@@ -35,8 +35,8 @@
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="src\concurrency\Util.cpp">
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">HAVE_GETTIMEOFDAY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">HAVE_GETTIMEOFDAY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="src\processor\PeekProcessor.cpp">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -217,7 +217,8 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;HAVE_CONFIG_H;NOMINMAX;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ForcedIncludeFiles>force_inc.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -231,7 +232,8 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;HAVE_CONFIG_H;NOMINMAX;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ForcedIncludeFiles>force_inc.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h
index 97f7987..60a66f4 100644
--- a/lib/cpp/src/Thrift.h
+++ b/lib/cpp/src/Thrift.h
@@ -20,6 +20,10 @@
#ifndef _THRIFT_THRIFT_H_
#define _THRIFT_THRIFT_H_ 1
+#ifdef _WIN32
+#include "windows/config.h"
+#endif
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/lib/cpp/src/transport/TSocket.cpp b/lib/cpp/src/transport/TSocket.cpp
index 48d0007..2db8f8b 100644
--- a/lib/cpp/src/transport/TSocket.cpp
+++ b/lib/cpp/src/transport/TSocket.cpp
@@ -181,10 +181,6 @@
void TSocket::openConnection(struct addrinfo *res) {
-#ifdef _WIN32
- TWinsockSingleton::create();
-#endif // _WIN32
-
if (isOpen()) {
return;
}
@@ -276,7 +272,7 @@
goto done;
}
- if (errno != EINPROGRESS) {
+ if ((errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {
int errno_copy = errno;
GlobalOutput.perror("TSocket::open() connect() " + getSocketInfo(), errno_copy);
throw TTransportException(TTransportException::NOT_OPEN, "connect() failed", errno_copy);
@@ -346,6 +342,11 @@
}
void TSocket::local_open(){
+
+#ifdef _WIN32
+ TWinsockSingleton::create();
+#endif // _WIN32
+
if (isOpen()) {
return;
}
diff --git a/lib/cpp/src/windows/TargetVersion.h b/lib/cpp/src/windows/TargetVersion.h
index 7374666..c8498b1 100644
--- a/lib/cpp/src/windows/TargetVersion.h
+++ b/lib/cpp/src/windows/TargetVersion.h
@@ -28,6 +28,9 @@
#error This is a MSVC header only.
#endif
+#include <winsdkver.h>
+
+#define _WIN32_WINNT 0x0601
#include <SDKDDKVer.h>
#endif //_THIRFT_WINDOWS_TARGETVERSION_H_
diff --git a/lib/cpp/src/windows/config.h b/lib/cpp/src/windows/config.h
index 29a01f6..0f9a304 100644
--- a/lib/cpp/src/windows/config.h
+++ b/lib/cpp/src/windows/config.h
@@ -28,6 +28,11 @@
#error This is a MSVC header only.
#endif
+#pragma warning(disable: 4996) // Depreciated posix name.
+#pragma warning(disable: 4250) // Inherits via dominance.
+
+#define HAVE_GETTIMEOFDAY 1
+
#include "TargetVersion.h"
#include "GetTimeOfDay.h"
#include "Operators.h"
@@ -50,27 +55,31 @@
// pthreads
#include <pthread.h>
-//"asm/posix_types.h"
-typedef unsigned int __kernel_size_t;
-typedef int __kernel_ssize_t;
-
-//"linux/types.h"
-typedef __kernel_size_t size_t;
-typedef __kernel_ssize_t ssize_t;
-
-// Missing defines.
-#define __BYTE_ORDER __LITTLE_ENDIAN
+typedef ptrdiff_t ssize_t;
// Missing functions.
#define usleep(ms) Sleep(ms)
-#if WINVER == 0x0501
-# define poll(fds, nfds, timeout) \
- select(0, NULL, fds, NULL, timeout)
-#else
-# define poll(fds, nfds, timeout) \
- WSAPoll(fds, nfds, timeout)
-#endif // WINVER
+#define poll(fds, nfds, timeout) \
+ poll_win32(fds, nfds, timeout)
+
+inline int poll_win32(LPWSAPOLLFD fdArray, ULONG fds, INT timeout)
+{
+ fd_set read_fds;
+ fd_set write_fds;
+ fd_set except_fds;
+
+ FD_ZERO(&read_fds);
+ FD_ZERO(&write_fds);
+ FD_ZERO(&except_fds);
+
+ FD_SET(fdArray[0].fd, &read_fds);
+ FD_SET(fdArray[0].fd, &write_fds);
+ FD_SET(fdArray[0].fd, &except_fds);
+
+ timeval time_out = {timeout * 0.001, timeout * 1000};
+ return select(1, &read_fds, &write_fds, &except_fds, &time_out);
+}
inline void close(SOCKET socket)
{
diff --git a/lib/cpp/src/windows/force_inc.h b/lib/cpp/src/windows/force_inc.h
index aa81c42..a85b880 100644
--- a/lib/cpp/src/windows/force_inc.h
+++ b/lib/cpp/src/windows/force_inc.h
@@ -28,6 +28,10 @@
#error This is a MSVC header only.
#endif
+#define NOMINMAX
+
+#include "windows/config.h"
+
#undef gai_strerror
#define gai_strerror gai_strerrorA