From 47b886602a2cb289fa3efbb373921880546c85bd Mon Sep 17 00:00:00 2001 From: catbot Date: Wed, 27 May 2026 03:15:19 +0000 Subject: [PATCH] fix: unbreak mingw build of Crafter.Build-Clang Two Windows-only compile errors blocked the mingw cross-compile: * `` transitively includes ``, which defines `#define interface struct`. The file uses `interface` as a loop variable name in three for-loops, so on mingw it expanded into `for(... struct : ...)` and cascaded into a wall of unrelated parse errors. Undefine the macro right after the Windows headers in the global module fragment. * `static_cast` in the port-probe helper failed because mingw's `` typedefs are in the global module fragment and the C-namespace `::uint16_t` isn't anchored into the module purview on this toolchain. `import std;` does export `std::uint16_t`, so qualify the cast. Verified by running `crafter-build --target=x86_64-w64-mingw32` end to end and the full test suite (13 passed, 5 environment-skipped). --- implementations/Crafter.Build-Clang.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/implementations/Crafter.Build-Clang.cpp b/implementations/Crafter.Build-Clang.cpp index db81f13..dd8c674 100644 --- a/implementations/Crafter.Build-Clang.cpp +++ b/implementations/Crafter.Build-Clang.cpp @@ -21,6 +21,9 @@ module; #if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32) #include #include +// (pulled in transitively) defines `interface` as a macro for `struct`, +// which collides with local variables named `interface` in this TU. +#undef interface #else #include #include @@ -1471,7 +1474,7 @@ int Crafter::Run(int argc, char** argv) { sockaddr_in addr{}; addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_ANY); - addr.sin_port = htons(static_cast(p)); + addr.sin_port = htons(static_cast(p)); bool ok = ::bind(s, reinterpret_cast(&addr), sizeof(addr)) == 0; closesock(s); if (ok) return p; -- 2.54.0