autoconf
[Top][All Lists]
Advanced

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

Re: c99


From: Guido Draheim
Subject: Re: c99
Date: Sun, 14 Oct 2001 20:14:11 +0200

address@hidden 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.
* 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. 
* 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.
* 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 ;-)
* 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

looking forward, and good luck, Guido

> 
> define(TEST_C99_DECL, AC_TRY_COMPILE([],[
>   int x=0; x+=1; int y=0;
>   for (int z=0; z < 2; z++);
> ],[C99=yes],[C99=no]))
> 
> AC_MSG_CHECKING([whether $CC accepts C99 declarations])
> TEST_C99_DECL
> if test $C99 = no -a $GCC = yes; then
>   save_CFLAGS="$CFLAGS"
>   CFLAGS="$CFLAGS -std=gnu99"
>   TEST_C99_DECL
>   if test $C99 = no; then
>     CFLAGS="$save_CFLAGS"
>   else
>     C99_COMMENT=', with -std=gnu99'
>   fi
> fi
> 
> if test $C99 = yes; then
>   echo "yes$C99_COMMENT"
> 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
> fi
> 
> --
> Victory to the Divine Mother!!
>   http://sahajayoga.org

-- guido                            Edel sei der Mensch, hilfreich und gut
GCS/E/S/P C++$++++ ULHS L++w- N++@ d(+-) s+a- r+@>+++ y++ 5++X- (geekcode)



reply via email to

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