Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MIB_IPADDRROW.wType for MinGW w64 #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

drewbarbs
Copy link

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 from netioapi.h (included by iphlpapi.h) [2][3], which caused the inclusion of declarations that reference types like ADDRESS_FAMILY and SOCKADDR_STORAGE that are not present unless winsock2.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

Andrew Barbarello added 2 commits May 19, 2015 15:31
Include winsock2.h in check_struct_member test program.
CheckStructHasMember module has been around since CMake 2.6 according to
http://www.cmake.org/Wiki/CMake_Version_Compatibility_Matrix/StandardCMakeModulesA
Current `cmake_minimum_required` is version 2.6 in top-level CMakeLists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant