Skip to content

Commit

Permalink
Merge pull request #1880 from MatthewPowley/fix-windows-xp-compatability
Browse files Browse the repository at this point in the history
Windows XP compatability fixes
  • Loading branch information
c-rack committed Mar 31, 2016
2 parents dac5b45 + f2018ab commit a7922e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions builds/msvc/properties/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@
</ClCompile>
</ItemDefinitionGroup>

<!-- When using a tool set to target Windows XP, define a pre-processor definition and modify the target Windows version -->
<ItemDefinitionGroup Condition="$(PlatformToolset.Contains('_xp'))">
<ClCompile>
<PreprocessorDefinitions>ZMQ_HAVE_WINDOWS_TARGET_XP;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>

</Project>
10 changes: 10 additions & 0 deletions src/tcp_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,23 @@ int zmq::tcp_address_t::resolve (const char *name_, bool local_, bool ipv6_, boo
std::string if_str = addr_str.substr(pos + 1);
addr_str = addr_str.substr(0, pos);
if (isalpha (if_str.at (0)))
#if !defined ZMQ_HAVE_WINDOWS_TARGET_XP
zone_id = if_nametoindex(if_str.c_str());
#else
// The function 'if_nametoindex' is not supported on Windows XP.
// If we are targeting XP using a vxxx_xp toolset then fail.
// This is brutal as this code could be run on later windows clients
// meaning the IPv6 zone_id cannot have an interface name.
// This could be fixed with a runtime check.
zone_id = 0;
#endif
else
zone_id = (uint32_t) atoi (if_str.c_str ());
if (zone_id == 0) {
errno = EINVAL;
return -1;
}

}

// Allow 0 specifically, to detect invalid port error in atoi if not
Expand Down

0 comments on commit a7922e5

Please sign in to comment.