Fix MIB_IPADDRROW.wType for MinGW w64 #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sigar's test for whether the
MIB_IPADDRROW
structure has a member named "wType
" (as would be the case on Windows XP and later [1]) fails when using MinGW-W64 4.9.1 (included with the latest version of Qt: 5.4 at time of writing). In September 2014, an "invalid version guard" was removed fromnetioapi.h
(included byiphlpapi.h
) [2][3], which caused the inclusion of declarations that reference types likeADDRESS_FAMILY
andSOCKADDR_STORAGE
that are not present unlesswinsock2.h
is included. To work around this issue, we include winsock2.h in our check program.Including
winsock2.h
should have no effect on the test when using MSVC (tested with VS2010, and with VS2014 via webcompiler.cloudapp.net). In fact, Microsoft's documentation states that "The Winsock2.h header file for Windows Sockets 2.0 is required by most applications using the IP Helper APIs" [4]. This issue with MinGW W64 has been reported elsewhere [5], and a similar workaround was added to the Ruby trunk to work around it [6][7]. In the meantime, adding this header should cause no harm, and seems a reasonable thing to do.Also included in this pull request is a refactor of
CMakeLists.txt
to use the CMake-provided function for checking if a struct has a desired member, instead of rolling our own. The module (CheckStructHasMember
) has been around since CMake 2.6 [8], the current minimum required version in the top-level CMakeLists.txt.[1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa366845%28v=vs.85%29.aspx
[2] http://sourceforge.net/p/mingw-w64/mingw-w64/ci/b2aa85ca326ca55a2965da168c3c2d1c508c5572/
[3] http://sourceforge.net/p/mingw-w64/mailman/message/32871176/
[4] https://msdn.microsoft.com/en-us/library/windows/desktop/aa365872%28v=vs.85%29.aspx
[5] http://stackoverflow.com/questions/29069904/why-does-mingw-w64-require-winsock2-to-be-manually-included
[6] https://bugs.ruby-lang.org/issues/10640
[7] https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/48997
[8] http://www.cmake.org/Wiki/CMake_Version_Compatibility_Matrix/StandardCMakeModulesA