[Top][All Lists]

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

Re: Call the AC_CHECK_HEADER macro on a condition

From: Eric Blake
Subject: Re: Call the AC_CHECK_HEADER macro on a condition
Date: Tue, 12 Apr 2016 09:24:21 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1

On 04/12/2016 09:05 AM, Nick Bowler wrote:

> But in your second instance, the first expansion of AC_CHECK_HEADER
> expands AC_PROG_CPP inside an "if".  The result is that no preprocessor
> is checked in the "else" case.  You can see this in the configure output,
> the following line is only printed in the avr case:
>   checking how to run the C preprocessor... avr-gcc -E
> There are several basic solutions:
> - First, you can just expand AC_PROG_CPP directly and unconditionally
>   before your if.  This will ensure the macro is available in both cases.
> - Second is to rewrite your condition using AS_IF, which automatically
>   "hoists" the dependency AC_PROG_CPP (and any other dependencies)
>   outside of the if condition.  For example:
>   AS_IF([test x"$host" = x"avr"],
>     [AC_CHECK_HEADER([avr/io.h], [],
>                      [AC_MSG_ERROR([missing header: avr/io.h])])
>      AC_CHECK_HEADER([util/delay.h], [],
>                      [AC_MSG_ERROR([missing header: util/delay.h])])],
>     [AC_CHECK_HEADER([stdio.h], [],
>                      [AC_MSG_ERROR([missing header: stdio.h])])

Also, checking for <stdio.h> is pointless these days.  You can portably
assume a C89 compiler (and these days, often a C99 compiler), which
guarantees <stdio.h> is present.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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