-
Notifications
You must be signed in to change notification settings - Fork 75
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 x86 build on Visual Studio (C++ 20 only) #220
Conversation
@@ -94,7 +95,7 @@ jobs: | |||
- name: Configure | |||
shell: bash | |||
working-directory: build/ | |||
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" -T ${{matrix.toolset}} | |||
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 17 2022" -T ${{matrix.toolset}} -A ${{matrix.arch}} |
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.
Updated this as C++ 20 wasn't being used with the old Clang version in VS 2019, and also to add the v143 toolset to the matrix.
@@ -132,7 +132,7 @@ struct pt_node_token : pt_node<Reader> | |||
if constexpr (_optimize_end) | |||
{ | |||
static_assert(!std::is_pointer_v<typename Reader::iterator> | |||
|| sizeof(pt_node_token) == 3 * sizeof(void*)); | |||
|| sizeof(pt_node_token) == 2 * sizeof(void*) + 8); |
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 saw some fixed size things in here and so updated this static assertion to let the 32-bit build compile, but it needs double-checking really.
This gets the Visual Studio build working for 32-bit builds for C++ 20 only. Previously, the `_BitScanForward64()` function was being used for Visual Studio, which is only available in 64-bit builds. This switches from `_BitScanForward64()` to `std::countr_zero()` for Visual Studio when C++ 20 or newer is used. C++ 17 remains unsupported for 32-bit builds in Visual Studio.
Thanks for reporting! I've decided to fix it for x86 without support, too. |
Hi,
I noticed that 32-bit builds with Visual Studio failed due to the use of
_BitScanForward64()
, which is only available in 64-bit builds.This tweaks things so that
std::countr_zero()
is used for Visual Studio when C++ 20 or newer is targetted. That fixes things for 32-bit builds in VS when C++ 20 is used, but 32-bit VS builds targetting C++ 17 remain unsupported.This fix is good enough for me, though I imagine you'd want to tweak things a bit (write access is enabled on the head branch).