Wireshark-dev: Re: [Wireshark-dev] warnings as errors ([Wireshark-users] Build problems with Su

From: Andrew Hood <ajhood@xxxxxxxxx>
Date: Sun, 10 Feb 2008 12:15:31 +1100
Guy Harris wrote:
> Andrew Hood wrote:
> 
> 
>>Is it possible to *not* treat warnings from system header includes as
>>errors? Otherwise --disable-warnings-as-errors will have to stay in my
>>config script.
> 
> 
> I don't know any way to tell GCC to treat warnings from some include 
> files differently from warnings from other include files or the main 
> source file.
> 
> (What warnings are your system headers producing?  On Solaris, for 
> example, we do -DFUNCPROTO=15 to cause the X11 headers to have prototype 
> declarations, and we also do -Wno-return-type for some reason.  It might 
> be possible to get rid of the warnings with your headers.)

/usr/include/bits/string2.h: In function `__strcpy_small':
/usr/include/bits/string2.h:428: warning: pointer of type `void *' used
in arithmetic
etc.

I've compared this with a more recent set of header files (glibc 2.5)
and /usr/include/bits/string2.h hasn't changed significantly. It still
has the same constructs.

What *has* changed is gcc's behaviour. Newer versions have a
system-headers warning option.

You will need to test if gcc will accept -Wno-system-headers, in order
to leave -Werror as the default.

I haven't tested it, but some thing like this might work.


: diff -u configure.in configure.in.oldgcc
--- configure.in        2008-01-07 05:58:16.000000000 +1100
+++ configure.in.oldgcc 2008-02-10 12:06:07.000000000 +1100
@@ -231,7 +231,18 @@
 # This barrier is set for a very large part of the code. However, it is
 # typically not set for "generated" code  (lex, ans2wrs, idl2wrs, ...)
 #
-warnings_as_errors_default="yes"
+
+# Older versions of gcc generate errors for system header files.
+# For these, warnings-as-errors has to default to "no"
+CFLAGS_saved="$CFLAGS"
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-system-headers)
+if text "x$CFLAGS" = "$CFLAGS_saved"; then
+  warnings_as_errors_default="no"
+else
+  warnings_as_errors_default="yes"
+fi
+CFLAGS="$CFLAGS_saved"
+
 AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
 AC_ARG_ENABLE(warnings-as-errors,
   AC_HELP_STRING( [--enable-warnings-as-errors],



-- 
There's no point in being grown up if you can't be childish sometimes.
                -- Dr. Who