ARTICLE AD BOX
I’m working on building Alembic using MXE, where my host is Linux (Ubuntu running under WSL on Windows) and the target is Windows.
#if defined _WIN32 #include <Windows.h> #endifThis works fine when compiling natively on Windows. However, when cross-compiling with MXE, _WIN32 and _WIN64 are defined even though the host is Linux, so <Windows.h> does not exist and the build fails. Removing these #if checks and their contents allows the build to succeed.
I initially looked at this StackOverflow answer: Is there a compiler macro to detect Windows?, which suggests using _WIN32. But in MXE cross-compilation, _WIN32 is not reliable, because it only indicates a Windows target, not a native Windows host.
Question:
Is there a preprocessor macro, CMake variable, or other method to reliably detect a native Windows build versus a cross-compilation target?
This would allow projects like Alembic to include Windows headers only when they’re actually available, avoiding cross-compilation failures. For more context, here's the specific issue I encountered:
4
