diff --git a/makefiles/cflags.inc.mk b/makefiles/cflags.inc.mk
index eabc6f0193a21cad85ef9782d766577e498469a6..48f52c9cd0a8ae71fa54f1b24ddec79165adc63b 100644
--- a/makefiles/cflags.inc.mk
+++ b/makefiles/cflags.inc.mk
@@ -28,7 +28,7 @@ endif
 # Template for testing a compiler flag and adding it to CFLAGS (errors usually
 # happens when using older toolchains which do not support the given flags)
 define cflags_test_and_add
-  ifeq ($(shell $(CC) $(1) -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
+  ifeq ($(shell $(CC) -Werror $(1) -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
     CFLAGS += $(1)
   endif
 endef