From 00b3941de5ea4dede10d3c41ab9e794641da182f Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 22 Aug 2024 20:55:40 +0200 Subject: [PATCH] change(build): add -Werror=return-type to default C and C++ flags (#10216) --- platform.txt | 8 ++++++-- tools/platformio-build.py | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platform.txt b/platform.txt index f3eb69f08..0c1ff5bf5 100644 --- a/platform.txt +++ b/platform.txt @@ -46,10 +46,14 @@ compiler.warning_flags.default= compiler.warning_flags.more=-Wall compiler.warning_flags.all=-Wall -Wextra +# Additional flags specific to Arduino (not based on IDF flags). +# Update tools/platformio-build.py when changing these flags. +compiler.common_werror_flags=-Werror=return-type + # Compile Flags compiler.cpreprocessor.flags="@{compiler.sdk.path}/flags/defines" "-I{build.source.path}" -iprefix "{compiler.sdk.path}/include/" "@{compiler.sdk.path}/flags/includes" "-I{compiler.sdk.path}/{build.memory_type}/include" -compiler.c.flags="@{compiler.sdk.path}/flags/c_flags" {compiler.warning_flags} {compiler.optimization_flags} -compiler.cpp.flags="@{compiler.sdk.path}/flags/cpp_flags" {compiler.warning_flags} {compiler.optimization_flags} +compiler.c.flags="@{compiler.sdk.path}/flags/c_flags" {compiler.warning_flags} {compiler.optimization_flags} {compiler.common_werror_flags} +compiler.cpp.flags="@{compiler.sdk.path}/flags/cpp_flags" {compiler.warning_flags} {compiler.optimization_flags} {compiler.common_werror_flags} compiler.S.flags="@{compiler.sdk.path}/flags/S_flags" {compiler.warning_flags} {compiler.optimization_flags} compiler.c.elf.flags="@{compiler.sdk.path}/flags/ld_flags" "@{compiler.sdk.path}/flags/ld_scripts" compiler.c.elf.libs="@{compiler.sdk.path}/flags/ld_libs" diff --git a/tools/platformio-build.py b/tools/platformio-build.py index 06b5dac2e..1ece3afdd 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -164,6 +164,15 @@ SConscript( ) ) +# +# Additional flags specific to Arduino core (not based on IDF) +# + +env.Append( + CFLAGS=["-Werror=return-type"], + CXXFLAGS=["-Werror=return-type"], +) + # # Target: Build Core Library #