James Youngman [EMAIL PROTECTED] 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
[EMAIL PROTECTED]