Skip to content

Commit 38e4171

Browse files
committed
fix: add missing warning for incompatible pointer types in CMake configuration
1 parent d7afa4c commit 38e4171

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

build-scripts/warnings.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ else ()
1616
#
1717
# -fpermissive causes warnings like "-fpermissive is valid for C++/ObjC++ but not for C"
1818
#
19+
# Reference:
20+
# - gcc-4.8 https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Warning-Options.html
21+
# - gcc-11.5 https://gcc.gnu.org/onlinedocs/gcc-11.5.0/gcc/Warning-Options.html
1922
add_compile_options (
20-
$<$<COMPILE_LANGUAGE:C>:-Wincompatible-pointer-types>
2123
$<$<COMPILE_LANGUAGE:C>:-Wimplicit-function-declaration>
2224
)
25+
# https://gcc.gnu.org/gcc-5/changes.html introduces incompatible-pointer-types
26+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "5.1")
27+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wincompatible-pointer-types>)
28+
endif()
29+
# options benefit embedded system.
2330
add_compile_options (
2431
-Wdouble-promotion
2532
)

0 commit comments

Comments
 (0)