fix(build): set -Wunused-but-set-variable=1 for GNU compiler to maintain backward compatibility

This commit is contained in:
Alexey Lapshin
2026-06-17 17:24:25 +07:00
parent 7d8c01b879
commit 71618c88e3
3 changed files with 22 additions and 1 deletions
+10 -1
View File
@@ -17,8 +17,17 @@ DEBUG_SHELL=${DEBUG_SHELL:-"0"}
# (Depends on default options '-Wno-error=XXX' used in the IDF build system)
if [ "$IDF_TOOLCHAIN" != "clang" ]; then
PEDANTIC_FLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
PEDANTIC_FLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-function"
export PEDANTIC_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
# TODO IDF-15784
case "$CI_JOB_NAME" in
test_pytest_linux|test_sockets_on_host|test_transport_on_host|test_pytest_macos)
export PEDANTIC_CFLAGS="${PEDANTIC_CFLAGS} -Werror=unused-but-set-variable"
;;
*)
export PEDANTIC_CFLAGS="${PEDANTIC_CFLAGS} -Werror=unused-but-set-variable=1"
;;
esac
else
export PEDANTIC_CFLAGS="-Werror"
fi
+6
View File
@@ -236,6 +236,12 @@ function(__init_project_configuration)
list(APPEND c_compile_options "-Wno-old-style-declaration")
endif()
# TODO IDF-15784: remove in IDF v7.0 ?
check_c_compiler_flag("-Wunused-but-set-variable=1" compiler_supports_wunused_but_set_variable_eq_1)
if(compiler_supports_wunused_but_set_variable_eq_1)
list(APPEND compile_options "-Wunused-but-set-variable=1")
endif()
# Clang finds some warnings in IDF code which GCC doesn't.
# All these warnings should be fixed before Clang is presented
# as a toolchain choice for users.