On 03/17/2010 06:58 PM, Grégoire Sutre wrote:
> Just out of curiosity: is there a reason for this behavior of
> AC_CHECK_DECLS, which, quoting the manual, is unlike the other
> ‘AC_CHECK_*S’ macros?

Yes - it looks cleaner to write code like:

if (CONDITION)
  do_something ();

than

#if CONDITION
  do_something ();
#endif

but that only works if CONDITION is always defined to 0 or 1.  In
general, we prefer to avoid #if inside function bodies; it is easier to
read code where all the #if have been factored out to file scope level
and function bodies are straight-line code.  Newer autoconf macros
follow this style, and gnulib continues it for most macros defined by
gnulib.  And even for the older autoconf macros which did not follow
this paradigm, it's not too hard to do:

#ifndef CONDITION
# define CONDITION
#endif

at the top of the file, to once again keep #if out of function bodies.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to