meson: Do hard build error for some MSVC warnings
authorSeungha Yang <seungha@centricular.com>
Fri, 1 Oct 2021 11:27:28 +0000 (20:27 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 16 Feb 2022 17:03:29 +0000 (17:03 +0000)
Handle various MSVC warnings as errors for development version.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1006>

16 files changed:
subprojects/gst-libav/meson.build
subprojects/gst-plugins-bad/gst-libs/gst/vulkan/win32/gstvkwindow_win32.c
subprojects/gst-plugins-bad/gst/festival/gstfestival.c
subprojects/gst-plugins-bad/meson.build
subprojects/gst-plugins-bad/sys/ipcpipeline/gstipcpipelinecomm.c
subprojects/gst-plugins-bad/sys/mediafoundation/gstmfvideoencoder.cpp
subprojects/gst-plugins-bad/tests/examples/nvcodec/nvcodec.c
subprojects/gst-plugins-base/gst-libs/gst/gl/winrt/gstglwindow_winrt_egl.cpp
subprojects/gst-plugins-base/meson.build
subprojects/gst-plugins-base/tests/examples/seek/instant-rate-change.c
subprojects/gst-plugins-good/meson.build
subprojects/gst-plugins-ugly/meson.build
subprojects/gstreamer/meson.build
subprojects/gstreamer/tests/check/gst/gstmeta.c
subprojects/gstreamer/tests/check/gst/gstpoll.c
subprojects/gstreamer/tools/gst-inspect.c

index 99e0731..159b455 100644 (file)
@@ -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
 
index dd87671..5bc513c 100644 (file)
@@ -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)
index 0876776..5420ec0 100644 (file)
@@ -95,6 +95,8 @@
 #ifdef G_OS_WIN32
 #include <winsock2.h>
 #include <ws2tcpip.h>
+/* dup, read, close */
+#include <io.h>
 #else
 #include <sys/socket.h>
 #include <netdb.h>
index 1b0d19e..782a0df 100644 (file)
@@ -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
index 3dde660..7d9d720 100644 (file)
@@ -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 <io.h>
 #endif
 #include <errno.h>
 #include <string.h>
index 31b3cdb..2b4c67f 100644 (file)
@@ -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;
index f5c2b8a..31064a7 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <gst/gst.h>
 #include <gst/video/video.h>
+#include <stdlib.h>
 
 #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:");
index 5b822c6..60882e6 100644 (file)
@@ -318,8 +318,6 @@ public:
   bool
   GetWindowSize (guint * width, guint * height)
   {
-    bool ret = true;
-
     if (!isValid_)
       return false;
 
index b933d7f..cea8dff 100644 (file)
@@ -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
index ca2957b..7aeb294 100644 (file)
@@ -30,6 +30,7 @@
 #include <glib-object.h>
 #include <glib/gprintf.h>
 #include <gst/gst.h>
+#include <stdlib.h>
 
 /* 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
index 381905e..db8792c 100644 (file)
@@ -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
index ae6aabb..e4ad221 100644 (file)
@@ -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
index 6b4db5c..a0076f8 100644 (file)
@@ -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
index 765774d..c407bef 100644 (file)
@@ -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;
index 78e73ef..dbf1631 100644 (file)
@@ -28,6 +28,7 @@
 #ifdef G_OS_WIN32
 #include <winsock2.h>
 #include <fcntl.h>
+#include <io.h>
 #else
 #include <unistd.h>
 #include <sys/socket.h>
index b7bf806..7056f8e 100644 (file)
 #   include <sys/wait.h>
 #endif
 
+#ifdef G_OS_WIN32
+/* _isatty() */
+#include <io.h>
+#endif
 
 /* "R" : support color
  * "X" : do not clear the screen when leaving the pager