Commit 5de723749f6d7f83f243781bfec6ee5f1d3b12aa

Cameron Gutman 2021-11-05T21:06:58

SDL_config_windows.h: detect winsdkver.h using __has_include() __has_include() was added in VS 2017 15.3, so this works out to essentially the same _MSC_VER >= 1911 check we had before for MSVC but works for non-MSVC compilers also.

diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h
index 5853e5d..dac4b7d 100644
--- a/include/SDL_config_windows.h
+++ b/include/SDL_config_windows.h
@@ -25,9 +25,16 @@
 
 #include "SDL_platform.h"
 
-/* winsdkver.h defines _WIN32_MAXVER for SDK version detection. It is present since at least the Windows 7 SDK.
- * Define NO_WINSDKVER_H if your SDK version doesn't provide this, or use CMake which can detect it automatically. */
-#ifndef NO_WINSDKVER_H
+/* winsdkver.h defines _WIN32_MAXVER for SDK version detection. It is present since at least the Windows 7 SDK,
+ * but out of caution we'll only use it if the compiler supports __has_include() to confirm its presence.
+ * If your compiler doesn't support __has_include() but you have winsdkver.h, define HAVE_WINSDKVER_H.  */
+#if !defined(HAVE_WINSDKVER_H) && defined(__has_include)
+#if __has_include(<winsdkver.h>)
+#define HAVE_WINSDKVER_H 1
+#endif
+#endif
+
+#ifdef HAVE_WINSDKVER_H
 #include <winsdkver.h>
 #endif