platform.h: detect MSVC ARM64 as 64-bit and raise 32-bit Windows minimum - #409
Merged
bkaradzic merged 1 commit intoJul 23, 2026
Merged
Conversation
Two related Windows fixes: * BX_ARCH_64BIT missed MSVC's _M_ARM64 / _M_ARM64EC, so Windows on ARM64 was treated as a 32-bit architecture. Add them to the 64-bit detection list. * The 32-bit Windows branch defaulted WINVER / _WIN32_WINNT to 0x0502 (Windows XP / Server 2003), which predates APIs that modern SDK headers reference (e.g. the ETW EventRegister/EventWriteTransfer family, only declared for _WIN32_WINNT >= 0x0600). Raise it to 0x0601 (Windows 7), matching the 64-bit branch. Combined with the ARM64 detection fix, x86, x64 and ARM64 Windows targets now all default to a Windows 7 baseline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 45aaf3cc-900d-442b-a7e5-0fb6d3fe6658
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Two related Windows fixes in
include/bx/platform.h:1. Detect MSVC ARM64 as 64-bit
The
BX_ARCH_64BITdetection lists__aarch64__(GCC/Clang) but not MSVC's_M_ARM64/_M_ARM64EC. As a result, Windows-on-ARM64 built with MSVC is treated as a 32-bit architecture, which is incorrect and affects everything keyed offBX_ARCH_64BIT(pointer-size assumptions, the Windows version default below, etc.). Added_M_ARM64and_M_ARM64ECto the 64-bit list.2. Raise the 32-bit Windows minimum
The 32-bit Windows branch defaulted
WINVER/_WIN32_WINNTto0x0502(Windows XP / Server 2003). That predates APIs modern Windows SDK headers reference unconditionally — e.g. the ETWEventRegister/EventUnregister/EventWriteTransferfamily in<evntprov.h>, which is only declared for_WIN32_WINNT >= 0x0600. Building a 32-bit target that transitively includes such headers fails witherror C3861: 'EventRegister': identifier not found.Raised the 32-bit default to
0x0601(Windows 7), matching the existing 64-bit branch. With both fixes, x86, x64 and ARM64 Windows targets default to a consistent Windows 7 baseline. Callers that need a different target can still defineWINVER/_WIN32_WINNTthemselves — the defaults remain guarded by!defined(...).Testing
Compiled a TU including
<bx/platform.h>with MSVC forx86,x64andarm64, asserting_WIN32_WINNT >= 0x0600(andBX_ARCH_64BIT == 64for ARM64) — all pass. Against the previous code, thex86andarm64targets fail those assertions (they resolved to0x0502).