Fix compiling for Arm64 Windows with MSVC #483
Draft
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.
This PR fixes 3 issues when compiling for Arm64 Windows with MSVC.
defined(__X86_64__) || defined(__aarch64__)
check with a platform-agnosticUINTPTR_MAX == UINT64_MAX
that relies onstdint.h
(please let me know if any of Embree's targets do not havestdint.h
, my assumption is that this is fine to depend on, but I know that MSVC versions from before 2010 don't have it). MSVC does not define__aarch64__
, but it does define_M_ARM64
. Adding|| defined(_M_ARM64)
would also fix the problem, but it's best to make this platform-agnostic.bsf
,bscf
, andbsr
. Without it, this function was not being defined on MSVC. Same as the above point, MSVC does not define__aarch64__
, but it does define_M_ARM64
. Adding|| defined(_M_ARM64)
would also fix the problem, but it's best to make this platform-agnostic. Usingsize_t
with#if
guards for 64-bit is the same as just usinguint64_t
. Note that functions may be automatically removed by the compiler if unused, so there is no reason to explicitly wrap it in#if
guards.#include <immintrin.h>
, check if_M_ARM64
is defined (meaning Arm64 Windows MSVC) and if so defineUSE_SOFT_INTRINSICS
. MSVC providesimmintrin.h
with software support on Arm64, but this has to be enabled explicitly. The MSVC-providedimmintrin.h
contains this code: