[vlc-devel] [PATCH] vlc_fixups: allow overriding the minimum Windows SDK for certain files

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 6 14:47:37 CET 2020


We often use this to compile code targeting newer versions of Windows than the
minimal version we support.

This trick allows setting the proper SDK before including any header apart from
config.h (which forces the inclusion of vlc_fixups.h).
---
 include/vlc_fixups.h                         | 5 +++++
 modules/codec/avcodec/directx_va.h           | 5 +----
 modules/video_output/win32/d3d11_quad.c      | 7 ++-----
 modules/video_output/win32/d3d11_shaders.c   | 5 +----
 modules/video_output/win32/d3d11_swapchain.c | 6 ++----
 modules/video_output/win32/direct3d11.c      | 7 ++-----
 modules/video_output/win32/win32touch.h      | 8 ++------
 7 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 8fd01da0ce7..e80acde938f 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -26,6 +26,11 @@
 #ifndef LIBVLC_FIXUPS_H
 # define LIBVLC_FIXUPS_H 1
 
+#if defined(FORCE_WIN32_MIN_WINNT) && defined(_WIN32_WINNT) && _WIN32_WINNT < FORCE_WIN32_MIN_WINNT
+# undef _WIN32_WINNT
+# define _WIN32_WINNT FORCE_WIN32_MIN_WINNT
+#endif
+
 /* needed to detect uClibc */
 #ifdef HAVE_FEATURES_H
 #include <features.h>
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index 80663674ef5..14d0086a41d 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -27,11 +27,8 @@
 #ifndef AVCODEC_DIRECTX_VA_H
 #define AVCODEC_DIRECTX_VA_H
 
-# if _WIN32_WINNT < _WIN32_WINNT_VISTA
 /* d3d11 needs Vista support */
-#  undef _WIN32_WINNT
-#  define _WIN32_WINNT _WIN32_WINNT_VISTA
-# endif
+#define FORCE_WIN32_MIN_WINNT 0x0600 // _WIN32_WINNT_VISTA
 
 #include <vlc_common.h>
 
diff --git a/modules/video_output/win32/d3d11_quad.c b/modules/video_output/win32/d3d11_quad.c
index 41dea2950bb..11a764121f0 100644
--- a/modules/video_output/win32/d3d11_quad.c
+++ b/modules/video_output/win32/d3d11_quad.c
@@ -20,6 +20,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#define FORCE_WIN32_MIN_WINNT 0x0601 // _WIN32_WINNT_WIN7
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -27,11 +29,6 @@
 #include <assert.h>
 #include <vlc_common.h>
 
-#if !defined(_WIN32_WINNT) || _WIN32_WINNT < _WIN32_WINNT_WIN7
-# undef _WIN32_WINNT
-# define _WIN32_WINNT _WIN32_WINNT_WIN7
-#endif
-
 #define COBJMACROS
 #include <d3d11.h>
 
diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 09826bf521a..cf2063ef720 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -20,10 +20,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#if !defined(_WIN32_WINNT) || _WIN32_WINNT < _WIN32_WINNT_WIN7
-# undef _WIN32_WINNT
-# define _WIN32_WINNT _WIN32_WINNT_WIN7
-#endif
+#define FORCE_WIN32_MIN_WINNT 0x0601 // _WIN32_WINNT_WIN7
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index 2360854bd3d..987d2f4d104 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -21,6 +21,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#define FORCE_WIN32_MIN_WINNT 0x0601 // _WIN32_WINNT_WIN7
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -34,10 +36,6 @@
 #include <assert.h>
 
 #include <windows.h>
-#if !defined(_WIN32_WINNT) || _WIN32_WINNT < _WIN32_WINNT_WIN7
-# undef _WIN32_WINNT
-# define _WIN32_WINNT _WIN32_WINNT_WIN7
-#endif
 
 #define COBJMACROS
 #include <initguid.h>
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index d6558e21e3d..ea40c5d498e 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -21,6 +21,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#define FORCE_WIN32_MIN_WINNT 0x0601 // _WIN32_WINNT_WIN7
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -38,11 +40,6 @@
 #include <assert.h>
 #include <math.h>
 
-#if !defined(_WIN32_WINNT) || _WIN32_WINNT < _WIN32_WINNT_WIN7
-# undef _WIN32_WINNT
-# define _WIN32_WINNT _WIN32_WINNT_WIN7
-#endif
-
 #define COBJMACROS
 #include <initguid.h>
 #include <d3d11.h>
diff --git a/modules/video_output/win32/win32touch.h b/modules/video_output/win32/win32touch.h
index ea854282bfe..4ebb9e2a536 100644
--- a/modules/video_output/win32/win32touch.h
+++ b/modules/video_output/win32/win32touch.h
@@ -24,12 +24,8 @@
 #ifndef VLC_GESTURE_H_
 #define VLC_GESTURE_H_
 
-# if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x601
-#  undef _WIN32_WINNT
-#  define _WIN32_WINNT 0x0601
-# endif
-# include <windows.h>
-# include <winuser.h>
+#define FORCE_WIN32_MIN_WINNT 0x0601 // _WIN32_WINNT_WIN7
+#define WINVER FORCE_WIN32_MIN_WINNT
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
-- 
2.17.1



More information about the vlc-devel mailing list