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 build failure on UCRT mingw64 #199

Closed
wants to merge 2 commits into from
Closed

Conversation

Morilli
Copy link
Contributor

@Morilli Morilli commented Jul 28, 2021

closes #198.

Note that #define __MSVCRT_VERSION__ WINVER is the only thing that broke the build, but I've removed the others regardless because

  1. it doesn't feel right to define some of these and not others
  2. Looks like they're bound to cause issues in the future as well

Note that the resulting binary does change after removing #define _WIN32_IE WINVER... don't ask me why, I genuinely have no idea why the internet explorer is of any relevancy here. Chose to ignore and move on 👍

@Screwtapello
Copy link
Contributor

Hmm, apparently this breaks the Windows builds on both GitHub and CirrusCI. I guess some of those defines must be important.

@Morilli
Copy link
Contributor Author

Morilli commented Jul 28, 2021

From what I can tell so far, it is missing WSAPoll, which is defined in winsock2.h iff _WIN32_WINNT >= 0x0600.
On my system, there is a _mingw.h header that does #define _WIN32_WINNT 0x601 and is included from windows.h which in turn gets included in winsock2.h iff _INC_WINDOWS is NOT defined.
_INC_WINDOWS only gets defined if windows.h was already included from what I can see.

That means the only reasonable explanation for the failure is that on whatever system the CI is running, _WIN32_WINNT gets defined to a value lower than 0x0600 in _mingw.h or even not at all.
According to microsoft's documentation, the value 0x0600 corresponds to windows vista. Is the build running on an even older system (or in some compatibility mode or whatever)?

@Morilli
Copy link
Contributor Author

Morilli commented Jul 28, 2021

Okay, I have checked version 8.0.2 of mingw-w64 (even though the CI uses 8.1, but I couldn't find that online), which defines #define _WIN32_WINNT 0x502.

I'm using msys2/mingw, which uses the current trunk version of mingw-w64 (which is version 9+) and defines what I wrote above.

I guess for the sake of supporting this Windows Server 2003 define, I will re-add the WINNT and WINVER defines and see how it goes then.

@Screwtapello
Copy link
Contributor

I think it's a good idea to explicitly ask for the version of Windows we intend to support, regardless of what the toolchain defaults might happen to be.

Thanks for figuring this out!

@Screwtapello
Copy link
Contributor

I squashed these two commits and merged the result: 41f30f3

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.

<nall/windows/guard.hpp> is broken on ucrt
2 participants