diff --git a/DynamicLoader.cxx b/DynamicLoader.cxx
index 158ad27bb7c200f73d88cfe1ab53d1422ebe4e7b..b93a215ccdaf66084cc447e8d60342e133254bb6 100644
--- a/DynamicLoader.cxx
+++ b/DynamicLoader.cxx
@@ -1,5 +1,9 @@
 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
    file Copyright.txt or https://cmake.org/licensing#kwsys for details.  */
+#if defined(_WIN32)
+#  define NOMINMAX // hide min,max to not conflict with <limits>
+#endif
+
 #include "kwsysPrivate.h"
 #include KWSYS_HEADER(DynamicLoader.hxx)
 
@@ -212,6 +216,8 @@ const char* DynamicLoader::LastError()
 // Implementation for Windows win32 code but not cygwin
 #  include <windows.h>
 
+#  include <stdio.h>
+
 namespace KWSYS_NAMESPACE {
 
 DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(