Subject: | Incorrect use of Windows macros |
The Windows macros WINVER, _WIN32_WINNT, and NTDDI_VERSION are defined
by the SDK to the highest version supported by the SDK if the user's
code doesn't define them. As such, they are not indicative of the
version of Windows being used but the version of the SDK that was used
by the compile.
This means the NTDDI_VERSION check that is included in config.pl is
incorrect since it will be true for anyone building with a recent SDK
regardless of whether the version of Windows which they are running.
So, while Socket6 currently builds on versions of Windows earlier than
Vista it will not run there due to inet_(ntop|pton) not being part of
the networking library pre-Vista.
Unless run-time library detection is going to be used, config.pl should
unconditionally "#undef HAVE_INET_NTOP" and "#undef HAVE_INET_PTON" for
Windows. Subsequently, Socket6.xs should use the following instead of
defining WINVER.
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#define NTDDI_VERSION NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT)
Ideally, you'd be able to simply set NTDDI_VERSION and it would properly
set _WIN32_WINNT and WINVER. Unfortunately, there was a problem in
Visual Studio 2008 which requires specifying _WIN32_WINNT, but that can
then be used to set NTDDI_VERSION (and NTDDI_VERSION will be used to set
WINVER and the other macros appropriately).
This fixes the issues with running the built xs modules on pre-Vista
systems. As well, it still runs fine on Vista or later systems because
the macros restrict the Windows headers from using anything that wasn't
present in XP, thus using the inet_(pton|ntop) that come with Socket6.
There's a, likely related, issue with taking a Socket6 PPM built on a
Windows XP system and running it on a Windows 2003 system which I
haven't been able to figure out yet, but everything's fine if the module
is built on the same Windows version that it will be running on.