diff --git a/CMakeLists.txt b/CMakeLists.txt index f351fe1cd82..16869142c47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1607,6 +1607,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") # warning level: "/W3" "/w34062" # switch statement contains 'default' but no 'case' labels + "/w34100" # 'identifier' : unreferenced formal parameter "/w34115" # 'type' : named type definition in parentheses "/w34189" # local variable is initialized but not referenced # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017 diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 958c8205bfd..92e36767cad 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -702,6 +702,7 @@ macro(remove_strict_flags) endif() if(MSVC) + remove_cc_flag(/w34100) # Restore warn C4100 (unreferenced formal parameter) back to w4 remove_cc_flag(/w34189) # Restore warn C4189 (unused variable) back to w4 endif() @@ -721,7 +722,7 @@ macro(remove_extra_strict_flags) endif() if(MSVC) - # TODO + remove_cc_flag(/w34100) # Restore warn C4100 (unreferenced formal parameter) back to w4 endif() endmacro() diff --git a/intern/guardedalloc/intern/mallocn_intern.h b/intern/guardedalloc/intern/mallocn_intern.h index c2e9f9117bc..14e5c171e7e 100644 --- a/intern/guardedalloc/intern/mallocn_intern.h +++ b/intern/guardedalloc/intern/mallocn_intern.h @@ -10,6 +10,9 @@ #ifdef __GNUC__ # define UNUSED(x) UNUSED_##x __attribute__((__unused__)) +#elif defined(_MSC_VER) +/* NOTE: This suppresses the warning for the line, not the attribute. */ +# define UNUSED(x) UNUSED_##x __pragma(warning(suppress : 4100)) #else # define UNUSED(x) UNUSED_##x #endif diff --git a/intern/mantaflow/CMakeLists.txt b/intern/mantaflow/CMakeLists.txt index 60ca19c35ff..7a92301b9ed 100644 --- a/intern/mantaflow/CMakeLists.txt +++ b/intern/mantaflow/CMakeLists.txt @@ -15,6 +15,13 @@ if(WIN32) add_definitions(-D_USE_MATH_DEFINES) endif() +if(WIN32) + # Some files in extern are being included which brings up a bunch of + # "unreferenced formal parameter" warnings. + # So restore warn C4100 (unreferenced formal parameter) back to w4 + remove_cc_flag(/w34100) +endif() + set(INC extern diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index e03bc7ba78a..35e3345f4c2 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -668,6 +668,9 @@ extern bool BLI_memory_is_zero(const void *arr, size_t arr_size); /* UNUSED macro, for function argument */ # if defined(__GNUC__) || defined(__clang__) # define UNUSED(x) UNUSED_##x __attribute__((__unused__)) +# elif defined(_MSC_VER) +/* NOTE: This suppresses the warning for the line, not the attribute. */ +# define UNUSED(x) UNUSED_##x __pragma(warning(suppress : 4100)) # else # define UNUSED(x) UNUSED_##x # endif diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt index 21017d1be88..568ed4c7641 100644 --- a/source/blender/io/usd/CMakeLists.txt +++ b/source/blender/io/usd/CMakeLists.txt @@ -35,6 +35,13 @@ if(USD_IMAGING_HEADERS) add_definitions(-DUSD_HAS_IMAGING) endif() +if(WIN32) + # Some USD library headers trigger the "unreferenced formal parameter" + # warning alert. + # Silence them by restore warn C4100 back to w4 + remove_cc_flag(/w34100) +endif() + set(INC . ../common diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 2988b7e2e35..98c2b2e53fd 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -140,6 +140,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang")) endif() if(CMAKE_C_COMPILER_ID MATCHES "Clang") string(APPEND GENSRC_CFLAGS " -Wno-missing-variable-declarations") +elseif(MSVC) + # Restore warn C4100 (unreferenced formal parameter) back to w4 + remove_cc_flag(/w34100) endif() if(GENSRC_CFLAGS) diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c index f860bdc36ee..6ac9cd64f33 100644 --- a/source/blender/python/intern/stubs.c +++ b/source/blender/python/intern/stubs.c @@ -12,6 +12,9 @@ #if defined(__GNUC__) || defined(__clang__) # pragma GCC diagnostic error "-Wmissing-prototypes" # pragma GCC diagnostic ignored "-Wunused-parameter" +#elif defined(_MSC_VER) +/* Suppress unreferenced formal parameter warning. */ +# pragma warning(disable : 4100) #endif /* python, will come back */