-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix mingw-w64 building #2198
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 mingw-w64 building #2198
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider this a kludge. Any chance to define/redefine _WIN32_WINNT to the appropriate value outside? Otherwise what about a macro HAVE_CREATEFILE2?
What can we do if Code could be like: #if defined(HAVE_CREATEFILE2)
hFile_ = ::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
OPEN_EXISTING, NULL);
#else
hFile_ = ::CreateFileW(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif Edited: CreateFileW has different arguments, fixed. |
The code has been updated. I add the macro |
47075dd
to
86adf1f
Compare
@apocelipes thanks for the pull request. However, I don't prefer seeing |
Or, I am thinking to use only CreateFileW in httplib.h. :) |
@yhirose Thanks for your review. I think use The code can be simplified and no need to introduce a new macro. You could take a look at the new code:
This is more simple than use |
We already have the Lines 29 to 34 in 3f44c80
CreateFileW will not be used then. |
So, the I can add a cmake check to set the macro |
A cmake compile check has been added. PTAL. |
I upgraded the toolchain and it fixed. I think this PR is no longer needed. Thank you for your advice. |
Since v0.23.1 cpp-httplib can not be complied with mingw-w64. The error message looks like this:
You can find the whole CI log here: link
The function
::CreateFile2
needs_WIN32_WINNT >= 0x0602
, however mingw-w64 in our CI cannot detect the correct value of it and set the value to0x0600
and0x0502
, that makes the code cannot useCreateFile2
.Because cpp-httplib requires Windows 10 or newer, let's just set the
_WIN32_WINNT
to_WIN32_WINNT_WIN10
if we are using mingw-w64. Now mingw-w64 should compile the code.