From: Pierre d'Herbemont Date: Thu, 20 Aug 2009 14:39:33 +0000 (+0200) Subject: configure: Treat unused param or value as error when building with --enable-debug. X-Git-Tag: 1.1.0-ff~4122 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c2786a86cdcb0d17e84bb3b3f9eb30a548139898;p=vlc configure: Treat unused param or value as error when building with --enable-debug. Warnings that are 'safe' to be treated as error should be added here as well. I hope this will raise VLC code quality, and tend to lower the hudge number of warnings. Some of them are sometimes letal but hidden by others. --- diff --git a/configure.ac b/configure.ac index 4006896aa4..a3d0f5b0b2 100644 --- a/configure.ac +++ b/configure.ac @@ -1008,6 +1008,13 @@ CFLAGS="${CFLAGS_save}" RDC_PROG_CC_WFLAGS([all extra sign-compare undef pointer-arith bad-function-cast cast-align write-strings missing-prototypes volatile-register-var error-implicit-function-declaration]) RDC_PROG_CC_FLAGS_IFELSE([-pipe]) +AC_ARG_ENABLE(warnings-as-error, + AS_HELP_STRING([--enable-warnings-as-error],[Treat acceptable warnings as error (default disabled, enabled in debug)])) +if test "x${warnings_as_error}" = "xyes" -o "x${enable_debug}" != "xno" +then + RDC_PROG_CC_WERRORFLAGS([unused-function unused-label unused-value unused-parameter unused-variable unused]) +fi + dnl Check for various optimization flags AC_CACHE_CHECK([if \$CC accepts -Os], [ac_cv_c_os], @@ -1132,7 +1139,7 @@ dnl Check for __attribute__((packed)) AC_CACHE_CHECK([for __attribute__((packed))], [ac_cv_c_attribute_packed], [ac_cv_c_attribute_packed=no - AC_TRY_COMPILE(, [struct __attribute__((__packed__)) foo { int a; } b;], + AC_TRY_COMPILE(, [struct __attribute__((__packed__)) foo { int a; } b; (void)b;], [ac_cv_c_attribute_packed=yes])]) if test "${ac_cv_c_attribute_packed}" != "no"; then AC_DEFINE(HAVE_ATTRIBUTE_PACKED, 1, Support for __attribute__((packed)) for structs) diff --git a/m4/flags.m4 b/m4/flags.m4 index 0bf8c3b163..326a90933a 100644 --- a/m4/flags.m4 +++ b/m4/flags.m4 @@ -31,6 +31,12 @@ AC_DEFUN([RDC_PROG_CC_FLAGS_IFELSE], ]) ]) +AC_DEFUN([RDC_PROG_CC_WERRORFLAGS], +[ for a in $1; do + RDC_PROG_CC_FLAGS_IFELSE([-Werror=$a]) + done +]) + AC_DEFUN([RDC_PROG_CC_WFLAGS], [ for a in $1; do RDC_PROG_CC_FLAGS_IFELSE([-W$a])