From e1f0687b09a19755a04cd16628ec099faa65acc7 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 1 Oct 2021 20:27:28 +0900 Subject: [PATCH] meson: Do hard build error for some MSVC warnings Handle various MSVC warnings as errors for development version. Part-of: --- subprojects/gst-libav/meson.build | 25 +++++++++++++++---- .../gst/vulkan/win32/gstvkwindow_win32.c | 3 +++ .../gst/festival/gstfestival.c | 2 ++ subprojects/gst-plugins-bad/meson.build | 25 +++++++++++++++---- .../sys/ipcpipeline/gstipcpipelinecomm.c | 2 ++ .../sys/mediafoundation/gstmfvideoencoder.cpp | 2 ++ .../tests/examples/nvcodec/nvcodec.c | 4 +++ .../gst/gl/winrt/gstglwindow_winrt_egl.cpp | 2 -- subprojects/gst-plugins-base/meson.build | 25 +++++++++++++++---- .../tests/examples/seek/instant-rate-change.c | 1 + subprojects/gst-plugins-good/meson.build | 25 +++++++++++++++---- subprojects/gst-plugins-ugly/meson.build | 25 +++++++++++++++---- subprojects/gstreamer/meson.build | 25 +++++++++++++++---- .../gstreamer/tests/check/gst/gstmeta.c | 2 +- .../gstreamer/tests/check/gst/gstpoll.c | 1 + subprojects/gstreamer/tools/gst-inspect.c | 4 +++ 16 files changed, 140 insertions(+), 33 deletions(-) diff --git a/subprojects/gst-libav/meson.build b/subprojects/gst-libav/meson.build index 99e0731e05..159b455820 100644 --- a/subprojects/gst-libav/meson.build +++ b/subprojects/gst-libav/meson.build @@ -115,12 +115,27 @@ if cc.get_id() == 'msvc' '/wd4244', # lossy type conversion (e.g. double -> int) '/wd4305', # truncating type conversion (e.g. double -> float) cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 - - # Enable some warnings on MSVC to match GCC/Clang behaviour - '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled - '/w14101', # 'identifier' : unreferenced local variable - '/w14189', # 'identifier' : local variable is initialized but not referenced ] + + if gst_version_is_dev + # Enable some warnings on MSVC to match GCC/Clang behaviour + msvc_args += cc.get_supported_arguments([ + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4020', # 'function' : too many actual parameters + '/we4027', # function declared without formal parameter list + '/we4029', # declared formal parameter list different from definition + '/we4033', # 'function' must return a value + '/we4045', # 'array' : array bounds overflow + '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4053', # one void operand for '?:' + '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled + '/we4098', # 'function' : void function returning a value + '/we4101', # 'identifier' : unreferenced local variable + '/we4189', # 'identifier' : local variable is initialized but not referenced + ]) + endif add_project_arguments(msvc_args, language: ['c', 'cpp']) endif diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/win32/gstvkwindow_win32.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/win32/gstvkwindow_win32.c index dd87671553..5bc513c75b 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/win32/gstvkwindow_win32.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/win32/gstvkwindow_win32.c @@ -67,6 +67,9 @@ static gboolean gst_vulkan_window_win32_open (GstVulkanWindow * window, static void gst_vulkan_window_win32_close (GstVulkanWindow * window); static void release_parent_win_id (GstVulkanWindowWin32 * window_win32); static void gst_vulkan_window_win32_show (GstVulkanWindowWin32 * window); +static gboolean +gst_vulkan_window_win32_create_window (GstVulkanWindowWin32 * window_win32, + GError ** error); static void gst_vulkan_window_win32_class_init (GstVulkanWindowWin32Class * klass) diff --git a/subprojects/gst-plugins-bad/gst/festival/gstfestival.c b/subprojects/gst-plugins-bad/gst/festival/gstfestival.c index 0876776c00..5420ec05e1 100644 --- a/subprojects/gst-plugins-bad/gst/festival/gstfestival.c +++ b/subprojects/gst-plugins-bad/gst/festival/gstfestival.c @@ -95,6 +95,8 @@ #ifdef G_OS_WIN32 #include #include +/* dup, read, close */ +#include #else #include #include diff --git a/subprojects/gst-plugins-bad/meson.build b/subprojects/gst-plugins-bad/meson.build index 1b0d19eb5e..782a0df2fa 100644 --- a/subprojects/gst-plugins-bad/meson.build +++ b/subprojects/gst-plugins-bad/meson.build @@ -64,12 +64,27 @@ if cc.get_id() == 'msvc' '/wd4244', # lossy type conversion (e.g. double -> int) '/wd4305', # truncating type conversion (e.g. double -> float) cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 - - # Enable some warnings on MSVC to match GCC/Clang behaviour - '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled - '/w14101', # 'identifier' : unreferenced local variable - '/w14189', # 'identifier' : local variable is initialized but not referenced ] + + if gst_version_is_dev + # Enable some warnings on MSVC to match GCC/Clang behaviour + msvc_args += cc.get_supported_arguments([ + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4020', # 'function' : too many actual parameters + '/we4027', # function declared without formal parameter list + '/we4029', # declared formal parameter list different from definition + '/we4033', # 'function' must return a value + '/we4045', # 'array' : array bounds overflow + '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4053', # one void operand for '?:' + '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled + '/we4098', # 'function' : void function returning a value + '/we4101', # 'identifier' : unreferenced local variable + '/we4189', # 'identifier' : local variable is initialized but not referenced + ]) + endif add_project_arguments(msvc_args, language: ['c', 'cpp']) # Disable SAFESEH with MSVC for plugins and libs that use external deps that # are built with MinGW diff --git a/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinecomm.c b/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinecomm.c index 3dde66004b..7d9d7208fa 100644 --- a/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinecomm.c +++ b/subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinecomm.c @@ -30,6 +30,8 @@ #ifdef _MSC_VER /* ssize_t is not available, so match return value of read()/write() on MSVC */ #define ssize_t int +/* read, write */ +#include #endif #include #include diff --git a/subprojects/gst-plugins-bad/sys/mediafoundation/gstmfvideoencoder.cpp b/subprojects/gst-plugins-bad/sys/mediafoundation/gstmfvideoencoder.cpp index 31b3cdbbc2..2b4c67f5d4 100644 --- a/subprojects/gst-plugins-bad/sys/mediafoundation/gstmfvideoencoder.cpp +++ b/subprojects/gst-plugins-bad/sys/mediafoundation/gstmfvideoencoder.cpp @@ -1479,7 +1479,9 @@ gst_mf_video_encoder_enum_internal (GstMFTransform * transform, GUID & subtype, gboolean have_I420 = FALSE; gboolean have_NV12 = FALSE; gboolean have_P010 = FALSE; +#if GST_MF_HAVE_D3D11 gboolean d3d11_aware = FALSE; +#endif gchar *device_name = nullptr; IMFActivate *activate; IMFTransform *encoder; diff --git a/subprojects/gst-plugins-bad/tests/examples/nvcodec/nvcodec.c b/subprojects/gst-plugins-bad/tests/examples/nvcodec/nvcodec.c index f5c2b8ad8c..31064a7171 100644 --- a/subprojects/gst-plugins-bad/tests/examples/nvcodec/nvcodec.c +++ b/subprojects/gst-plugins-bad/tests/examples/nvcodec/nvcodec.c @@ -23,6 +23,7 @@ #include #include +#include #include "nvcodec.h" @@ -53,6 +54,7 @@ restore_terminal (void) static void print_keyboard_help (void) { + /* *INDENT-OFF* */ static struct { const gchar *key_desc; @@ -68,6 +70,8 @@ print_keyboard_help (void) "<", "Decrease encoding bitrate by 100 kbit/sec"}, { "k", "show keyboard shortcuts"} }; + /* *INDENT-ON* */ + guint i, chars_to_pad, desc_len, max_desc_len = 0; g_print ("\n\n%s\n\n", "Keyboard controls:"); diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/winrt/gstglwindow_winrt_egl.cpp b/subprojects/gst-plugins-base/gst-libs/gst/gl/winrt/gstglwindow_winrt_egl.cpp index 5b822c641b..60882e67bc 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/winrt/gstglwindow_winrt_egl.cpp +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/winrt/gstglwindow_winrt_egl.cpp @@ -318,8 +318,6 @@ public: bool GetWindowSize (guint * width, guint * height) { - bool ret = true; - if (!isValid_) return false; diff --git a/subprojects/gst-plugins-base/meson.build b/subprojects/gst-plugins-base/meson.build index b933d7fe25..cea8dff4d8 100644 --- a/subprojects/gst-plugins-base/meson.build +++ b/subprojects/gst-plugins-base/meson.build @@ -62,12 +62,27 @@ if cc.get_id() == 'msvc' '/wd4244', # lossy type conversion (e.g. double -> int) '/wd4305', # truncating type conversion (e.g. double -> float) cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 - - # Enable some warnings on MSVC to match GCC/Clang behaviour - '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled - '/w14101', # 'identifier' : unreferenced local variable - '/w14189', # 'identifier' : local variable is initialized but not referenced ] + + if gst_version_is_dev + # Enable some warnings on MSVC to match GCC/Clang behaviour + msvc_args += cc.get_supported_arguments([ + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4020', # 'function' : too many actual parameters + '/we4027', # function declared without formal parameter list + '/we4029', # declared formal parameter list different from definition + '/we4033', # 'function' must return a value + '/we4045', # 'array' : array bounds overflow + '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4053', # one void operand for '?:' + '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled + '/we4098', # 'function' : void function returning a value + '/we4101', # 'identifier' : unreferenced local variable + '/we4189', # 'identifier' : local variable is initialized but not referenced + ]) + endif add_project_arguments(msvc_args, language: ['c', 'cpp']) # Disable SAFESEH with MSVC for plugins and libs that use external deps that # are built with MinGW diff --git a/subprojects/gst-plugins-base/tests/examples/seek/instant-rate-change.c b/subprojects/gst-plugins-base/tests/examples/seek/instant-rate-change.c index ca2957bb09..7aeb29476d 100644 --- a/subprojects/gst-plugins-base/tests/examples/seek/instant-rate-change.c +++ b/subprojects/gst-plugins-base/tests/examples/seek/instant-rate-change.c @@ -30,6 +30,7 @@ #include #include #include +#include /* There are several supported scenarios 0) Play rate to 1x -> Apply 'instant-rate-change' to 2x -> Apply 'instant-rate-change' to 0.25x (repeat as fast as possible for 2 sec) -> let play for 2s diff --git a/subprojects/gst-plugins-good/meson.build b/subprojects/gst-plugins-good/meson.build index 381905e8be..db8792c250 100644 --- a/subprojects/gst-plugins-good/meson.build +++ b/subprojects/gst-plugins-good/meson.build @@ -47,12 +47,27 @@ if cc.get_id() == 'msvc' '/wd4244', # lossy type conversion (e.g. double -> int) '/wd4305', # truncating type conversion (e.g. double -> float) cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 - - # Enable some warnings on MSVC to match GCC/Clang behaviour - '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled - '/w14101', # 'identifier' : unreferenced local variable - '/w14189', # 'identifier' : local variable is initialized but not referenced ] + + if gst_version_is_dev + # Enable some warnings on MSVC to match GCC/Clang behaviour + msvc_args += cc.get_supported_arguments([ + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4020', # 'function' : too many actual parameters + '/we4027', # function declared without formal parameter list + '/we4029', # declared formal parameter list different from definition + '/we4033', # 'function' must return a value + '/we4045', # 'array' : array bounds overflow + '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4053', # one void operand for '?:' + '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled + '/we4098', # 'function' : void function returning a value + '/we4101', # 'identifier' : unreferenced local variable + '/we4189', # 'identifier' : local variable is initialized but not referenced + ]) + endif if have_cxx add_project_arguments(msvc_args, language: ['c', 'cpp']) else diff --git a/subprojects/gst-plugins-ugly/meson.build b/subprojects/gst-plugins-ugly/meson.build index ae6aabbfa4..e4ad2217b7 100644 --- a/subprojects/gst-plugins-ugly/meson.build +++ b/subprojects/gst-plugins-ugly/meson.build @@ -48,12 +48,27 @@ if cc.get_id() == 'msvc' '/wd4244', # lossy type conversion (e.g. double -> int) '/wd4305', # truncating type conversion (e.g. double -> float) cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 - - # Enable some warnings on MSVC to match GCC/Clang behaviour - '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled - '/w14101', # 'identifier' : unreferenced local variable - '/w14189', # 'identifier' : local variable is initialized but not referenced ] + + if gst_version_is_dev + # Enable some warnings on MSVC to match GCC/Clang behaviour + msvc_args += cc.get_supported_arguments([ + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4020', # 'function' : too many actual parameters + '/we4027', # function declared without formal parameter list + '/we4029', # declared formal parameter list different from definition + '/we4033', # 'function' must return a value + '/we4045', # 'array' : array bounds overflow + '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4053', # one void operand for '?:' + '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled + '/we4098', # 'function' : void function returning a value + '/we4101', # 'identifier' : unreferenced local variable + '/we4189', # 'identifier' : local variable is initialized but not referenced + ]) + endif if have_cxx add_project_arguments(msvc_args, language: ['c', 'cpp']) else diff --git a/subprojects/gstreamer/meson.build b/subprojects/gstreamer/meson.build index 6b4db5cff1..a0076f8237 100644 --- a/subprojects/gstreamer/meson.build +++ b/subprojects/gstreamer/meson.build @@ -47,12 +47,27 @@ if cc.get_id() == 'msvc' '/wd4244', # lossy type conversion (e.g. double -> int) '/wd4305', # truncating type conversion (e.g. double -> float) cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 - - # Enable some warnings on MSVC to match GCC/Clang behaviour - '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled - '/w14101', # 'identifier' : unreferenced local variable - '/w14189', # 'identifier' : local variable is initialized but not referenced ] + + if gst_version_is_dev + # Enable some warnings on MSVC to match GCC/Clang behaviour + msvc_args += cc.get_supported_arguments([ + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4020', # 'function' : too many actual parameters + '/we4027', # function declared without formal parameter list + '/we4029', # declared formal parameter list different from definition + '/we4033', # 'function' must return a value + '/we4045', # 'array' : array bounds overflow + '/we4047', # 'operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4053', # one void operand for '?:' + '/we4062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled + '/we4098', # 'function' : void function returning a value + '/we4101', # 'identifier' : unreferenced local variable + '/we4189', # 'identifier' : local variable is initialized but not referenced + ]) + endif add_project_arguments(msvc_args, language: 'c') elif cc.has_link_argument('-Wl,-Bsymbolic-functions') # FIXME: Add an option for this if people ask for it diff --git a/subprojects/gstreamer/tests/check/gst/gstmeta.c b/subprojects/gstreamer/tests/check/gst/gstmeta.c index 765774d3e2..c407bef3bd 100644 --- a/subprojects/gstreamer/tests/check/gst/gstmeta.c +++ b/subprojects/gstreamer/tests/check/gst/gstmeta.c @@ -182,7 +182,7 @@ foo_transform_func (GstBuffer * transbuf, GstMeta * meta, g_quark_to_string (type), buffer, transbuf, meta); if (GST_META_TRANSFORM_IS_COPY (type)) { - G_GNUC_UNUSED GstMetaFoo *unused = GST_META_FOO_ADD (transbuf); + GST_META_FOO_ADD (transbuf); } else { /* return FALSE, if transform type is not supported */ return FALSE; diff --git a/subprojects/gstreamer/tests/check/gst/gstpoll.c b/subprojects/gstreamer/tests/check/gst/gstpoll.c index 78e73ef3df..dbf1631108 100644 --- a/subprojects/gstreamer/tests/check/gst/gstpoll.c +++ b/subprojects/gstreamer/tests/check/gst/gstpoll.c @@ -28,6 +28,7 @@ #ifdef G_OS_WIN32 #include #include +#include #else #include #include diff --git a/subprojects/gstreamer/tools/gst-inspect.c b/subprojects/gstreamer/tools/gst-inspect.c index b7bf8064ad..7056f8e6a8 100644 --- a/subprojects/gstreamer/tools/gst-inspect.c +++ b/subprojects/gstreamer/tools/gst-inspect.c @@ -41,6 +41,10 @@ # include #endif +#ifdef G_OS_WIN32 +/* _isatty() */ +#include +#endif /* "R" : support color * "X" : do not clear the screen when leaving the pager