]> git.sesse.net Git - vlc/commitdiff
configure: Treat unused param or value as error when building with --enable-debug.
authorPierre d'Herbemont <pdherbemont@free.fr>
Thu, 20 Aug 2009 14:39:33 +0000 (16:39 +0200)
committerPierre d'Herbemont <pdherbemont@free.fr>
Thu, 20 Aug 2009 14:43:26 +0000 (16:43 +0200)
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.

configure.ac
m4/flags.m4

index 4006896aa4ca4023389f88bbb33b9c10b459341a..a3d0f5b0b236e2fb07d581bf0ad3a2b1092caf2f 100644 (file)
@@ -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)
index 0bf8c3b163504591a9a40e69c4c40a436ac957ae..326a90933aab75fa02ce76f8c25ee2ef00ca2bd9 100644 (file)
@@ -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])