From e6b05bbe5c6fcbbbc417bb0a9f70089903bd6d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yeison=20Pati=C3=B1o?= <149027220+yeison-pati@users.noreply.github.com> Date: Thu, 19 Mar 2026 09:05:50 -0500 Subject: [PATCH] ggml-cpu: fix cross-compilation to Windows from Linux Fix compilation error when cross-compiling ggml-cpu for Windows using MinGW-w64 on Linux. The _WIN32_WINNT macro is only defined by MSVC headers, causing undefined macro warnings with GCC/MinGW. When cross-compiling llama.cpp for Windows from Linux using MinGW-w64, the `_WIN32_WINNT` macro is not defined (it's provided by MSVC SDK headers). This causes compilation warnings or errors. The fix adds `defined(_MSC_VER)` guard to ensure this Windows-specific code path is only evaluated when compiling with MSVC. --- ggml/src/ggml-cpu/ggml-cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.c index 8b323bd9b0..4f16c5c800 100644 --- a/ggml/src/ggml-cpu/ggml-cpu.c +++ b/ggml/src/ggml-cpu/ggml-cpu.c @@ -2491,7 +2491,7 @@ static bool ggml_thread_apply_priority(int32_t prio) { // Newer Windows 11 versions aggressively park (offline) CPU cores and often place // all our threads onto the first 4 cores which results in terrible performance with // n_threads > 4 - #if _WIN32_WINNT >= 0x0602 + #if defined(_MSC_VER) && _WIN32_WINNT >= 0x0602 THREAD_POWER_THROTTLING_STATE t; ZeroMemory(&t, sizeof(t)); t.Version = THREAD_POWER_THROTTLING_CURRENT_VERSION;