bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

adding bison's warning.m4


From: Jim Meyering
Subject: adding bison's warning.m4
Date: Thu, 04 May 2006 20:07:07 +0200

Any objection to adding a slight generalization of bison's warning.m4, below?
I'm going to use it in coreutils, so figured others might want to use it, too.
BTW, who's the author?  Paul?

First, here's how bison uses it:

AC_ARG_ENABLE(gcc-warnings,
[  --enable-gcc-warnings   turn on lots of GCC warnings (not recommended)],
[case "${enableval}" in
   yes|no) ;;
   *)      AC_MSG_ERROR([bad value ${enableval} for gcc-warnings option]) ;;
 esac],
              [enableval=no])
if test "${enableval}" = yes; then
  BISON_WARNING(-Werror)
  AC_SUBST([WERROR_CFLAGS], [$WARNING_CFLAGS])
  WARNING_CFLAGS=
  BISON_WARNING(-W)
  BISON_WARNING(-Wall)
  BISON_WARNING(-Wcast-align)
  BISON_WARNING(-Wcast-qual)
  BISON_WARNING(-Wformat)
  BISON_WARNING(-Wwrite-strings)
  AC_SUBST([WARNING_CXXFLAGS], [$WARNING_CFLAGS])
  # The following warnings are not suitable for C++.
  BISON_WARNING(-Wbad-function-cast)
  BISON_WARNING(-Wmissing-declarations)
  BISON_WARNING(-Wmissing-prototypes)
  BISON_WARNING(-Wshadow)
  BISON_WARNING(-Wstrict-prototypes)
  AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.])
fi

Obviously not for the faint of heart.
Here's the new file:

# serial 2
# Find valid warning flags for the C Compiler.
#
# Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301  USA

AC_DEFUN([gl_C_WARNING],
  [AC_MSG_CHECKING(whether compiler accepts $1)
   AC_SUBST(WARNING_CFLAGS)
   ac_save_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $1"
   AC_TRY_COMPILE(,
    [int x;],
    WARNING_CFLAGS="$WARNING_CFLAGS $1"
    AC_MSG_RESULT(yes),
    AC_MSG_RESULT(no))
  CFLAGS="$ac_save_CFLAGS"
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]