Skip to content

Commit

Permalink
Introduce a macro denoting which winapi version to use tied but diffe…
Browse files Browse the repository at this point in the history
…rent from which winapi version to include

(cherry picked from commit 439e988)
  • Loading branch information
trueqbit committed Dec 30, 2020
1 parent 1e658db commit aa06aa0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion build/pion.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
<Import Project="winapi.props" />
</ImportGroup>
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir>$(SolutionDir)bin\$(Configuration)_$(PlatformName)\</OutDir>
<IntDir>$(SolutionDir)IntermediateOutput\$(ProjectName)\$(Configuration)_$(PlatformName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;_WIN32_WINNT=0x0500;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
Expand Down
18 changes: 18 additions & 0 deletions build/winapi.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<WinApiSubfolder>winvista-support\</WinApiSubfolder>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0601;PION_USE_WINAPI_VERSION=_WIN32_WINNT;BOOST_USE_WINAPI_VERSION=BOOST_WINAPI_VERSION_WIN6;BOOST_USE_NTDDI_VERSION=BOOST_WINAPI_NTDDI_WIN6;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<BuildMacro Include="WinApiSubfolder">
<Value>$(WinApiSubfolder)</Value>
</BuildMacro>
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions cmake/config.hpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#ifndef PION_USE_WINAPI_VERSION
#define PION_USE_WINAPI_VERSION _WIN32_WINNT
#endif
#endif // _WIN32

#include <boost/config.hpp>
Expand Down
4 changes: 4 additions & 0 deletions include/pion/config.hpp.win
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@
#if defined(_WIN32) || defined(_WINDOWS)
#define PION_WIN32 1
#ifndef _WIN32_WINNT
#error Please properly define PION_USE_WINAPI_VERSION and/or _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#ifndef PION_USE_WINAPI_VERSION
#define PION_USE_WINAPI_VERSION _WIN32_WINNT
#endif
#else
#error PionConfig.hpp.win is for Win32 only.
#endif // _WIN32
Expand Down
2 changes: 1 addition & 1 deletion include/pion/tcp/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class connection :
/// note that the asio docs are misleading because close() is not thread-safe,
/// and the suggested #define statements cause WAY too much trouble and heartache
inline void cancel(void) {
#if !defined(_MSC_VER) || (_WIN32_WINNT >= 0x0600)
#if !defined(_MSC_VER) || (PION_USE_WINAPI_VERSION >= 0x0600)
boost::system::error_code ec;
m_ssl_socket.next_layer().cancel(ec);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/pion.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_DLL_full|x64'">
<PreBuildEvent>
<Message>Copying config.hpp.win -&gt;config.hpp</Message>
<Command>copy /Y $(SolutionDir)include\pion\config.hpp.win $(SolutionDir)include\pion\config.hpp</Command>
<Command>xcopy $(SolutionDir)include\pion\config.hpp.win $(SolutionDir)include\pion\config.hpp /y /d</Command>
</PreBuildEvent>
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
Expand Down

0 comments on commit aa06aa0

Please sign in to comment.