diff --git a/ggml.c b/ggml.c
index b124f14cc..64edc1175 100644
--- a/ggml.c
+++ b/ggml.c
@@ -1,6 +1,8 @@
#define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnings on Windows
#define _USE_MATH_DEFINES // For M_PI on MSVC
+// Load `stdlib.h` before other headers to work around MinGW bug: .
+#include
#include "ggml-impl.h"
#include "ggml-quants.h"
@@ -14,7 +16,6 @@
#include
#include
#include
-#include
#include
#include
#include