On 03/17/2010 05:00 PM, Grégoire Sutre wrote:
> Hi Eric,
> 
>> AC_CHECK_FUNCS leaves HAVE_FUNC undefined if it is missing, but defines
>> HAVE_FUNC to 1 if it is present.  It is much easier to write:
>>
>> #if HAVE_FUNC
> 
> In that case you only need to write:
> 
> #ifdef HAVE_FUNC
> 
> which is just as simple, and is compliant with -Wundef.

Then you contrast it with AC_CHECK_DECL, which defines

HAVE_FUNC_DECL

to either 0 or 1, but always defines it.  If you use #ifdef in those
situations, you lose (you typed 3 more bytes, and you get the wrong result).

It is a maintenance nightmare to remember which variables are defined as
0 and which are left undefined, and much simpler to blindly use #if than
it is to decide when #ifdef is necessary.

> Moreover, the documentation [1] of AC_CHECK_FUNCS actually does *not*
> guarantee that the value will be 1, it could as well be 0 (or -1234):

Actually, it DOES guarantee that it will be 1, but the guarantee is
(admittedly indirectly) specified elsewhere in the manual (that is,
AC_DEFINE defaults to 1 in the absence of any other value, and
AC_CHECK_FUNCS does not provide an interface to inject any other value.
 Autoconf will NOT be changing the use of AC_CHECK_FUNCS; but I am open
to doc patches to make this point more clear.

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