[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Maintainer checks for non-c89 constructs?
From: |
Ben Pfaff |
Subject: |
Re: Maintainer checks for non-c89 constructs? |
Date: |
Sat, 09 Jun 2007 09:27:36 -0700 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
"James Youngman" <address@hidden> writes:
> GCC accepts this construct because it is (or can be) a c99 compiler.
> I find that about twice a year someone submits a bug report because
> I've accidentally used a non-c89 construct without noticing. Is
> there any way I can use Automake to help me avoid this?
For this particular problem, you can write an Autoconf test to
check whether the C compiler accepts
-Wdeclaration-after-statement and use it if so.
In GNU PSPP we do it this way:
dnl Check whether a C compiler option is accepted.
dnl If so, add it to CFLAGS.
dnl Example: PSPP_ENABLE_OPTION(-Wdeclaration-after-statement)
AC_DEFUN([PSPP_ENABLE_OPTION],
[
m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name],
[pspp_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes],
[pspp_cv_name[]=no])
CFLAGS="$pspp_save_CFLAGS"])
if test $pspp_cv_name = yes; then
CFLAGS="$CFLAGS $1"
fi
])
PSPP_ENABLE_OPTION(-Wdeclaration-after-statement)
--
Ben Pfaff
address@hidden