dnl @synopsis AC_PROG_C99_DECL dnl dnl Try to find a compiler option to convince the compiler to accept dnl mixed statements and declarations. This macros also verifies dnl that declarations can be made inside a for loop. For example: dnl dnl int x=0; x+=1; int y=0; dnl for (int z=0; z < 2; z++); dnl dnl @version $Id$ dnl @author Joshua N Pritikin
define([AC_PROG_C99_DECL_TEST], [AC_TRY_COMPILE([],[ int x=0; x+=1; int y=0; for (int z=0; z < 2; z++); ],[ac_cv_prog_c99_decl=yes],[ac_cv_prog_c99_decl=no]) ]) AC_DEFUN([AC_PROG_C99_DECL], [ AC_MSG_CHECKING([whether $CC accepts C99 declarations]) AC_PROG_C99_DECL_TEST if test $ac_cv_prog_c99_decl = no -a $GCC = yes; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -std=gnu99" AC_PROG_C99_DECL_TEST if test $ac_cv_prog_c99_decl = no; then CFLAGS="$save_CFLAGS" else ac_cv_prog_c99_decl_fix=', with -std=gnu99' fi fi if test $ac_cv_prog_c99_decl = yes; then echo "yes$ac_cv_prog_c99_decl_fix" else AC_MSG_RESULT(no) AC_MSG_ERROR([ *** This package requires a C compiler with C99 support. Please *** consider trying a recent release of GCC.]) fi ])