diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 6110a334d108c1911aec98b47fb25396acff1cbb..b15b105487e428a6e03a94f88b931b44539d16c2 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -37,7 +37,13 @@
 #   undef lseek
 #  endif
 #  define lseek(f,p,w) _lseeki64((f), (p), (w))
+#  ifdef stat
+#   undef stat
+#  endif
 #  define stat _stati64
+#  ifdef fstat
+#   undef fstat
+#  endif
 #  define fstat(f,s) _fstati64((f), (s))
 #endif /* defined(__MINGW32__) && !defined(__MINGW32CE__) */