[vlc-devel] commit: configure: Treat unused param or value as error when building with --enable-debug. ( Pierre d'Herbemont )

git version control git at videolan.org
Thu Aug 20 16:43:35 CEST 2009


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Thu Aug 20 16:39:33 2009 +0200| [c2786a86cdcb0d17e84bb3b3f9eb30a548139898] | committer: Pierre d'Herbemont 

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c2786a86cdcb0d17e84bb3b3f9eb30a548139898
---

 configure.ac |    9 ++++++++-
 m4/flags.m4  |    6 ++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4006896..a3d0f5b 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 0bf8c3b..326a909 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])




More information about the vlc-devel mailing list