MSVC: lower C4100 warning level from 4 to 3
The C4100 warning is related to unused formal parameters in functions. Enabling it better aligns with "-Wunused-parameter" option in other compilers. While suppressing it with `__pragma(warning(suppress:4100))` is not the same as using `__attribute__((__unused__))` in GCC or Clang, it is still preferable to use it over completely hiding the warning. This ensures consistent warning behavior across compilers and improves code quality by addressing unused function parameters. (Note that some warnings in Windows-specific code have already been silenced in 7fcb262dfd2f48a73f9cf794944ff677c36e3783) Pull Request: https://projects.blender.org/blender/blender/pulls/105534
This commit is contained in:
parent
85fb63f99c
commit
f27d6b9640
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user