I've verified this works correctly with the Sun compilers, so +1
from me.

The one additional thought I have is should this take an optional
argument for the default value, so that maintainers can make it be
on by default in their modules on a case-by-case basis?
(Perhaps with arguments of "yes", "no" (the default), and "git"
  (yes if $(top_srcdir)/.git exists, otherwise no).)

One word of warning to those updating modules to use it - many modules
had the existing CWARNFLAGS added to FOO_CFLAGS in configure, so this
would need to come before that, something I missed on the first attempt
to test.  Better though would be to switch to our current best practice
of adding CWARNFLAGS to the CFLAGS in Makefile.am, so that it's easier
to override on the make command line when needed (though that's a lot
more work for modules like Xorg with dozens of Makefile.am, it's trivial
for most single-directory modules).

        -alan-

Peter Hutterer wrote:
> From: Pauli Nieminen <[email protected]>
> 
> Strict compilation option can be used to get rid of warnings that often are
> showing real hidden bug in code. That just waits to cause problems.
> 
> CWARNFLAGS has to be added to AM_C(PP)FLAGS to use strict compilation mode
> in Makefile.am. Automatic addition to compiler flags would cause some 
> configure
> checks fail.
> 
> X.Org Bug 22939 <http://bugs.freedesktop.org/show_bug.cgi?id=22939>
> 
> Signed-off-by: Peter Hutterer <[email protected]>
> ---
>  xorg-macros.m4.in |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index 1954714..5c22332 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -456,3 +456,32 @@ fi
>  AC_SUBST(CWARNFLAGS)
>  m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
>  ]) # XORG_CWARNFLAGS
> +
> +# XORG_STRICT_OPTION
> +# -----------------------
> +# Minimum version: 1.3.0
> +#
> +# Add configure option to enable strict compilation
> +AC_DEFUN([XORG_STRICT_OPTION], [
> +AC_REQUIRE([AC_PROG_CC])
> +AC_REQUIRE([AC_PROG_CC_C99])
> +AC_REQUIRE([XORG_CWARNFLAGS])
> +
> +AC_ARG_ENABLE(strict-compilation,
> +                       AS_HELP_STRING([--enable-strict-compilation],
> +                       [Enable all warnings from compiler and make them 
> errors (default: disabled)]),
> +                       [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
> +if test "x$STRICT_COMPILE" = "xyes"; then
> +     AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
> +     AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
> +     if test "x$GCC" = xyes ; then
> +             STRICT_CFLAGS="-pedantic -Werror"
> +     elif test "x$SUNCC" = "xyes"; then
> +             STRICT_CFLAGS="-errwarn"
> +    elif test "x$INTELCC" = "xyes"; then
> +             STRICT_CFLAGS="-Werror"
> +     fi
> +fi
> +CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
> +AC_SUBST([CWARNFLAGS])
> +]) # XORG_STRICT_OPTION


-- 
    -Alan Coopersmith-          [email protected]
     Sun Microsystems, Inc. - X Window System Engineering
_______________________________________________
xorg-devel mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to