[Vorbis-dev] [PATCH] : Add -Wdeclaration-after-statement

Erik de Castro Lopo mle+la at mega-nerd.com
Thu Aug 30 01:24:32 PDT 2007


Hi all,

It seems that with commit number 13652 I inadvertantly broken the
build.

The problem is that I'm using the default version of gcc on Ubuntu
which is gcc-4.1.2. It seems that this version is actually a C99 
compiler and C99 explicitly allows declarations after statements.
However, declarations after statements raise an error in earlier
versions of gcc. In short this is an error that could easily happen
to anyone who moved the this compiler without being aware of this
issue.

I will admit, that I was at least partially aware of this issue, but
have been using the gcc warning flag -Wdeclaration-after-statement 
in my own code to guard against this for some time. Unfortunately,
while working towards this commit this issue slipped my mind.

Since gcc-4.2 and later seems to be C99 and a lot of earlier compilers
still exist I suggest that the vorbis build be patched to add the 
required warning flag wherever it is available. The following patch
does the following:

  - Add an m4 directory containing the add_cflag.m4 macro which allows
    configure to test for the existance of a warning flag and add it
    to CFLAGS if it does exist.

  - Add AC_ADD_CFLAGS([-Wdeclaration-after-statement]) to the 
    appropriate place in configure.in.

  - Include the m4 directory in Makefile.am and fiddle configure.ac and
    autogen.sh to make sure all the dots are connected.

So, I'd like to apologise for breaking the build.

Cheers,
Erik

-----------------8<-----------------8<-----------------8<-----------------
Index: configure.in
===================================================================
--- configure.in	(revision 13657)
+++ configure.in	(working copy)
@@ -14,6 +14,10 @@
 AM_INIT_AUTOMAKE(libvorbis,1.2.1svn)
 AM_MAINTAINER_MODE
 
+dnl Add parameters for aclocal
+AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
+
+
 dnl Library versioning
 
 V_LIB_CURRENT=4
@@ -170,6 +174,8 @@
 		CFLAGS="-O20 -Wall -Wextra -D__NO_MATH_INLINES -fsigned-char"
 		PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
         esac
+
+	AC_ADD_CFLAGS([-Wdeclaration-after-statement])
 fi
 CFLAGS="$CFLAGS $cflags_save"
 
@@ -228,6 +234,7 @@
 
 AC_OUTPUT([
 Makefile
+m4/Makefile
 lib/Makefile
 lib/modes/Makefile
 lib/books/Makefile
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 13657)
+++ Makefile.am	(working copy)
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = 1.6 foreign dist-zip dist-bzip2
 
-SUBDIRS = lib include doc examples vq
+SUBDIRS = m4 lib include doc examples vq
 
 m4datadir = $(datadir)/aclocal
 m4data_DATA = vorbis.m4
Index: autogen.sh
===================================================================
--- autogen.sh	(revision 13657)
+++ autogen.sh	(working copy)
@@ -4,6 +4,8 @@
 
 package="vorbis"
 
+ACLOCAL_FLAGS="-I m4"
+
 olddir=`pwd`
 srcdir=`dirname $0`
 test -z "$srcdir" && srcdir=.

-----------------8<-----------------8<-----------------8<-----------------


-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"The fury with which untenable beliefs are defended is inversely
proportional to their defensibility."
-- Richard Dawkins


More information about the Vorbis-dev mailing list