Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Detect GCC vs Clang for compiler-specific warning flags

Martin Vogel93c0b865c4ba
diff --git a/Makefile.cbm b/Makefile.cbm
index ab136cf65..b2fd08ddd 100644
--- a/Makefile.cbm
+++ b/Makefile.cbm
@@ -33,9 +33,17 @@ LIBGIT2_FLAGS =
LIBGIT2_LIBS =
endif
+# GCC-only warning suppressions (Clang rejects unknown -Wno-* with -Werror).
+# Detect GCC by checking for __GNUC__ without __clang__ — handles all versions.
+IS_GCC := $(shell echo | $(CC) -dM -E - 2>/dev/null | grep -q '__GNUC__' && ! echo | $(CC) -dM -E - 2>/dev/null | grep -q '__clang__' && echo yes || echo no)
+GCC_ONLY_FLAGS :=
+ifeq ($(IS_GCC),yes)
+GCC_ONLY_FLAGS := -Wno-format-truncation -Wno-unused-result
+endif
+
CFLAGS_COMMON = -std=c11 -D_DEFAULT_SOURCE -Wall -Wextra -Werror \
-Wno-unused-parameter -Wno-sign-compare \
- -Wno-format-truncation -Wno-unused-result \
+ $(GCC_ONLY_FLAGS) \
-Isrc -Ivendored -Ivendored/sqlite3 \
-Ivendored/mimalloc/include \
-I$(CBM_DIR) -I$(TS_INCLUDE) \