Re: Call the AC_CHECK_HEADER macro on a condition

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

 



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 http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux