diff --git a/CMakeLists.txt b/CMakeLists.txt index d97f19424b..faa463d0c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -427,10 +427,11 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC") # Additional compiler warnings to be treated as "Level 3" # when compiling Wireshark sources. (Selected from "level 4" warnings). ## 4295: array is too small to include a terminating null character + ## 4100: unreferenced formal parameter ## 4189: local variable is initialized but not referenced # Disable warnings about about use of flexible array members: ## 4200: nonstandard extension used : zero-sized array in struct/union - list(APPEND LOCAL_CFLAGS /w34295 /w34189 /wd4200) + list(APPEND LOCAL_CFLAGS /w34295 /w34100 /w34189 /wd4200) # We've matched these to specific compiler versions using the # checks above. There's no need to pass them to check_c_compiler_flag diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c index 80304011d1..4a743558bc 100644 --- a/caputils/capture-pcap-util.c +++ b/caputils/capture-pcap-util.c @@ -823,12 +823,13 @@ linktype_name_to_val(const char *linktype) * rest-of-the-universe libpcap. */ int -get_pcap_datalink(pcap_t *pch, const char *devicename -#ifndef _AIX - _U_) +get_pcap_datalink(pcap_t *pch, +#ifdef _AIX + const char* devicename #else - ) + const char* devicename _U_ #endif + ) { int datalink; #ifdef _AIX @@ -1257,11 +1258,11 @@ get_if_capabilities_pcap_create(interface_options *interface_opts, } pcap_t * -open_capture_device_pcap_create(capture_options *capture_opts +open_capture_device_pcap_create( #if defined(HAVE_PCAP_SET_TSTAMP_PRECISION) || defined (HAVE_PCAP_SET_TSTAMP_TYPE) - , + capture_options* capture_opts, #else - _U_, + capture_options* capture_opts _U_, #endif interface_options *interface_opts, int timeout, cap_device_open_err *open_err, diff --git a/dumpcap.c b/dumpcap.c index 31a6ab8b05..fa20b402b8 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -591,9 +591,10 @@ relinquish_all_capabilities(void) static const char * get_pcap_failure_secondary_error_message(cap_device_open_err open_err, +#ifdef __hpux const char *open_err_str -#ifndef __hpux - _U_ +#else + const char* open_err_str _U_ #endif ) { diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c index 6b82e8b7f2..6a8a9201e2 100644 --- a/ui/win32/file_dlg_win32.c +++ b/ui/win32/file_dlg_win32.c @@ -1477,7 +1477,7 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { } static UINT_PTR CALLBACK -save_as_statstree_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { +save_as_statstree_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param _U_, LPARAM l_param _U_) { switch(msg) { case WM_INITDIALOG: diff --git a/ws_attributes.h b/ws_attributes.h index 7e2245b9c3..d7c4445323 100644 --- a/ws_attributes.h +++ b/ws_attributes.h @@ -27,6 +27,8 @@ extern "C" { #if defined(__GNUC__) /* This includes clang */ #define _U_ __attribute__((unused)) +#elif defined(_MSC_VER) + #define _U_ __pragma(warning(suppress:4100)) #else #define _U_ #endif diff --git a/wsutil/file_util.c b/wsutil/file_util.c index 745e2f3b43..a8a2a6bd2a 100644 --- a/wsutil/file_util.c +++ b/wsutil/file_util.c @@ -57,6 +57,7 @@ #include #include "file_util.h" +#include "ws_attributes.h" static gchar *program_path = NULL; static gchar *system_path = NULL; @@ -189,7 +190,7 @@ ws_stdio_rename (const gchar *oldfilename, const gchar *newfilename) * Since: 2.6 */ int -ws_stdio_mkdir (const gchar *filename, int mode) +ws_stdio_mkdir (const gchar *filename, int mode _U_) { wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); int retval; diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 72b3c9bf94..f56b4f0c48 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -469,9 +469,11 @@ get_executable_path(void) * g_mallocated string containing an error on failure. */ char * -init_progfile_dir(const char *arg0 +init_progfile_dir( #ifdef _WIN32 - _U_ + const char* arg0 _U_ +#else + const char* arg0 #endif ) { diff --git a/wsutil/getopt_long.c b/wsutil/getopt_long.c index c1f2b2a4cd..6e4d0070a8 100644 --- a/wsutil/getopt_long.c +++ b/wsutil/getopt_long.c @@ -19,6 +19,7 @@ #endif #include "config.h" +#include "ws_attributes.h" #include @@ -271,7 +272,13 @@ exchange (char **argv, struct _getopt_data *d) /* Initialize the internal data when the first call is made. */ static const char * -_getopt_initialize (int argc, char *const *argv, const char *optstring, +_getopt_initialize ( +#if defined _LIBC && defined USE_NONOPTION_FLAGS + int argc, char *const *argv, +#else + int argc _U_, char *const *argv _U_, +#endif + const char *optstring, struct _getopt_data *d, int posixly_correct) { /* Start processing options with ARGV-element 1 (since ARGV-element 0