From 09b77c40516aa1f87070343503745190e12eb23f Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Mon, 5 Jan 2026 18:49:59 -0600 Subject: [PATCH] cf: Work around differents in Wflags b. gcc and clang --- cf/wflags.m4 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cf/wflags.m4 b/cf/wflags.m4 index bc128bce7..efd88bf66 100644 --- a/cf/wflags.m4 +++ b/cf/wflags.m4 @@ -18,7 +18,24 @@ if test -z "$WFLAGS" -a "$GCC" = "yes"; then # -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast # -Wmissing-declarations -Wnested-externs # -Wstrict-overflow=5 - WFLAGS="ifelse($#, 0,-Wall, $1) $dwflags" + + # Check if this is Clang (which also sets GCC=yes for compatibility) + if $CC --version 2>&1 | grep -qi clang; then + rk_CLANG=yes + else + rk_CLANG=no + fi + + wflags="ifelse($#, 0,-Wall, $1)" + + # Replace GCC-specific warning flags with Clang equivalents + if test "$rk_CLANG" = yes; then + wflags=`echo "$wflags" | sed -e 's/-Wdiscarded-qualifiers/-Wignored-qualifiers/g' \ + -e 's/ -Wunused-but-set-variable//g' \ + -e 's/ -Wunused-const-variable//g'` + fi + + WFLAGS="$wflags $dwflags" # # WFLAGS_LITE can be appended to WFLAGS to turn off a host of warnings