Skip to content

Commit

Permalink
Cmake: Add Wshadow to default gcc builds.
Browse files Browse the repository at this point in the history
Warn whenever a local variable or type declaration shadows another variable,
parameter, or type. This will make sure (hopefully) that #611 don't come
back.

tested with:
 - cmake 3.13.4 & gcc 8.3.0 (debian)
 - cmake 3.13.4 & gcc 8.3.0 (Raspbian)
 - cmake 2.8.12.2 & gcc 4.8.2 (Zynq)

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz authored and dNechita committed Nov 11, 2020
1 parent 8b5a339 commit 75573e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ elseif (CMAKE_COMPILER_IS_GNUCC)
if (HAS_WPEDANTIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
endif()
check_c_compiler_flag(-Wshadow HAS_WSHADOW)
if (HAS_WSHADOW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
endif()
# cmake 2.8 doesn't support C_STANDARD defined in set_target_properties
if (${CMAKE_VERSION} VERSION_LESS "3.2")
check_c_compiler_flag(-std=c99 HAS_C99)
Expand Down

0 comments on commit 75573e6

Please sign in to comment.