[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: warnings expanding macros before they're required
From: |
Eric Blake |
Subject: |
Re: warnings expanding macros before they're required |
Date: |
Mon, 11 Jul 2011 13:50:42 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11 |
On 07/11/2011 01:31 PM, Mike Frysinger wrote:
> with this little bit of code:
> $ cat common.m4
> AC_DEFUN([SIM_AC_COMMON],[
> AC_PROG_CC
Change this to AC_REQUIRE([AC_PROG_CC]), and that should also avoid the
warning.
> AC_CHECK_HEADERS(stdlib.h string.h strings.h unistd.h time.h)
> ])
>
> $ cat configure.ac
> sinclude(common.m4)
> AC_INIT(Makefile.in)
I suggest using proper m4 quoting:
m4_sinclude([common.m4])
AC_INIT([Makefile.in])
> SIM_AC_COMMON
>
> running autoconf (2.64 and 2.68) results in the warnings:
2.64 doesn't produce the warnings; but silently produced a broken
configure instead. 2.68 outputs a fixed configure, at the expense of
outputting the code for AC_PROG_CC twice; the warning exists to tell you
that you can shrink the size of your configure by fixing things to avoid
the warning.
>
> this seems odd to me ... why would autoconf care if a macro is expanded
> before
> something requires it ?
Because without the warning, you have a silently broken configure.
The warning is trying to tell you that the AC_CHECK_HEADERS in
SIM_AC_COMMON depends on already knowing what $CC was set to, but that
it does so by doing an AC_REQUIRE([AC_PROG_CC]). In Autoconf 2.64, you
end up with this layout:
# prereqs to SIM_AC_COMMON
# prereqs to AC_CHECK_HEADERS, including code that uses $CC
# body of SIM_AC_COMMON
# body of AC_PROG_CC - now $CC is finally set
# body of AC_CHECK_HEADERS
In Autoconf 2.68, you end up with this layout:
# prereqs to SIM_AC_COMMON
# body of AC_PROG_CC - $CC is set before use
# prereqs to AC_CHECK_HEADERS, including code that uses $CC
# body of SIM_AC_COMMON
# body of AC_PROG_CC - redundant, hence the warning
# body of AC_CHECK_HEADERS
> guessing it's a bug because when i pull just
> AC_PROG_CC out of "SIM_AC_COMMON" and inline it before the call, autoconf
> doesnt warn:
> $ cat configure.ac
> sinclude(common.m4)
> AC_INIT(Makefile.in)
> AC_PROG_CC
> SIM_AC_COMMON
The bug is in the configure.ac file that is using SIM_AC_COMMON, for
using a pattern that triggered a silent bug in autoconf 2.64, but which
has since been fixed in 2.68.
http://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature