Fix MinGW build with _WIN32_WINNT<0x600, GCC>=13, model=win32 #132
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.
unordered_dense.h fails to compile on Windows/MinGW with GCC >= 13 with thread model win32, and _WIN32_WINNT < 0x600 (Vista), in CFLAGS/CXXFLAGS. E.g., GDB defines _WIN32_WINNT to 0x501, and it fails to build with GCC 14.2 like so:
The problem is that unordered_dense.h includes
<memory_resource>
, which usesstd::mutex
, and thus needs to include<mutex>
. (See https://quuxplusone.github.io/blog/2018/06/05/libcpp-memory-resource, "Notice that synchronized_pool_resource contains a mutex, which means that<memory_resource>
effectively must include<mutex>
.")GCC 13 rewrote the win32 thread model support, and in that rewrite, support for
__gthread_cond_t
instd_mutex.h
became conditional on_WIN32_WINNT >= 0x600
.GCC/libstdc++ also has
<experimental/memory_resource>
so with this patch, such a configuration takes that branch and succeeds, because<experimental/memory_resource>
does not include<mutex>
.Tested with MinGW-w64 GCC 14.2, posix and win32 models.
Tested with MinGW-w64 GCC 10.1, posix and win32 models.
Tested with GNU/Linux GCC 11.4.0.