On Sun, Oct 14, 2001 at 08:14:11PM +0200, Guido Draheim wrote:
> [EMAIL PROTECTED] wrote:
> > {..}
> > Is this stylistically acceptable?
> 
> *fg* oh well, speaking about style is (of course) a matter of taste
> and then a matter of whose taste it shall please. For a macro that
> you want to reuse in your own projects, yes looks good. 
> 
> Speaking as a maintainer of the (gnu) ac-archive, I would add just 
> some optional hints:
> * calling the macro TEST_C99 is not quite correct as you only test
>   one specific feature - so it would be good to call the macro as
>   just that, e.g. TEST_C99_FOR_BLOCK or whatever you like to call it.
>   Just see how many STL&C++template checks we currently have at the
>   ac-archive.. compilers might implement C99 features just partially.

Fixed.

> * tune your (internal and) exported variables, possibly just make them
>   longer so they do not accidently trap those of other macros, atleast
>   ensure to give a hint where a variable might have come from that another
>   macro might start to go and use - $C99 is probably not the best one.

Fixed.

> * you call a compile-test, even twice, and it looks as if this is a
>   case that can be turned into a macro using an AC_CACHE_CHECK value.
>   That's especially good during creation of configure-scrips as the
>   test can be run with a good cache-file that holds some answers
>   premade, and there is a good benefit in overly large projects that 
>   might be able to share a answer-file - and speed up their configure
>   time dramatically. 
> * Personally, I'd prefer the cache_val to contain the needed answer
>   of the test - well, I'd see the needed clfag -std=gnu99 as the answer.
> * in a highgrade extension, consider to add an ACTION-IF, ACTION-IF-NOT, 
>   ACTION-WITH-CFLAG triple along with an ifelse() that puts in default
>   actions like adding the needed cflag to CFLAGS. But that might be
>   overdone for what you need - it would just serve you in learning 
>   decent tricks one can do to make an autoconf-macro even more reusable ;-)

i can't figure this out right now.  :-)

> * anyway, I'd really like to have this macro in the ac-archive for
>   others to reuse (and let it be tested for you ;-)) ... just read the
>   small hints about the small extras that are needed to have it registered:
>   http://ac-archive.sourceforge.net/#formatting

Attached.  Enjoy.

-- 
Victory to the Divine Mother!!   ... after all, why compete?
  http://sahajayoga.org                http://why-compete.org
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 <[EMAIL PROTECTED]>

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
])

Reply via email to