Undef stat first
diff --git a/src/win32/mingw-compat.h b/src/win32/mingw-compat.h
index 83ee287..feedfec 100644
--- a/src/win32/mingw-compat.h
+++ b/src/win32/mingw-compat.h
@@ -9,6 +9,8 @@
#if defined(__MINGW32__)
+#undef stat
+
#if _WIN32_WINNT >= 0x0601
#define stat __stat64
#else