Skip to content

fix: Endian.ipp error on Windows for C++20 build#1334

Open
iantab wants to merge 1 commit intoSiv3D:v6_developfrom
iantab:fix/endian-cpp20-byteswap
Open

fix: Endian.ipp error on Windows for C++20 build#1334
iantab wants to merge 1 commit intoSiv3D:v6_developfrom
iantab:fix/endian-cpp20-byteswap

Conversation

@iantab
Copy link
Copy Markdown

@iantab iantab commented May 1, 2026

Problem

I ran into a build error using Siv3D headers under /std:c++20 on MSVC. Endian.ipp (Windows branch) uses std::byteswap, which is a C++23 library feature rather than C++20, so compilation fails with:

error C2039: 'byteswap': is not a member of 'std'

It builds fine under /std:c++latest (which is what Siv3D.vcxproj uses), so this only shows up when consuming the headers from a C++20 project.

Fix

Swap the three Windows-branch calls for the MSVC intrinsics _byteswap_ushort / _byteswap_ulong / _byteswap_uint64 from <cstdlib>. These are available regardless of /std: mode, so the Windows branch compiles cleanly under both /std:c++20 and /std:c++latest.

The macOS branch, the generic fallback, and the public Endian.hpp API are untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant