summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-22 01:26:18 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-22 01:29:57 +0200
commitface8e0a7d5f530ee3e5e63ab1e3d6ecd497326b (patch)
tree17444e0125da8e57cd34d3b3bc675d4332d76b47
parentbb61eeb6aecab1492b62426433af7c3c963a060b (diff)
Fix warnings for GCC as well
GCC ignores __attribute__((unused)) when compiling C++ code. (Yes, this is true) GCC -Wmaybe-uninitialized just gives false positives in my experience, so drop it. However, this exposed a problem with AX_APPEND_COMPILE_FLAGS and clang. clang gives a warning, but not an error, when given a -Wno-UNKNOWN-FLAG. So add -Werror as an extra flag to make clang fail on unknown -Wno-UNKNOWN-FLAG
-rw-r--r--configure.ac4
-rw-r--r--src/common.hh4
2 files changed, 5 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 53d0306..7564309 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,9 @@ CXXFLAGS="$OLDCXXFLAGS"
AX_CXXFLAGS_WARN_ALL([DEFINES])
AX_APPEND_COMPILE_FLAGS([-fno-rtti -fno-exceptions],DEFINES)
-AX_APPEND_COMPILE_FLAGS([-Wextra -Wno-missing-field-initializers],DEFINES)
+extra_flags=
+AX_CHECK_COMPILE_FLAG([-Werror], [extra_flags=-Werror])
+AX_APPEND_COMPILE_FLAGS([-Wextra -Wno-missing-field-initializers -Wno-maybe-uninitialized],DEFINES,[$extra_flags])
AC_ARG_ENABLE([debug], AC_HELP_STRING([compile with debug options]),
if test "x$enableval" = "xyes"; then
DEFINES="$DEFINES -g -O0 -DDEBUG"
diff --git a/src/common.hh b/src/common.hh
index 67c8fa5..95abcaa 100644
--- a/src/common.hh
+++ b/src/common.hh
@@ -7,10 +7,10 @@
# include "config.h"
#endif
-#if HAVE_VAR_ATTRIBUTE_UNUSED
+#if HAVE_VAR_ATTRIBUTE_UNUSED && !defined(__GNUG__)
# define UNUSED(x) __attribute__((unused)) x ## _unused
#else
-# define UNUSED(x) x ## _unused
+# define UNUSED(x) /* x ## _unused */
#endif
#include <cassert>