This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: AC_CHECK_DECLS(basename) (Was: Re: Ping: patches required for --enable-build-with-cxx)
- From: Paolo Bonzini <bonzini at gnu dot org>
- To: Joern Rennecke <joern dot rennecke at embecosm dot com>
- Cc: gcc at gcc dot gnu dot org, dj at redhat dot com, ian at airs dot com, neroden at gcc dot gnu dot org, aoliva at redhat dot com, Autoconf List <autoconf at gnu dot org>, Bruno Haible <bruno at clisp dot org>
- Date: Tue, 9 Feb 2010 10:15:03 +0100
- Subject: Re: AC_CHECK_DECLS(basename) (Was: Re: Ping: patches required for --enable-build-with-cxx)
- References: <20100208015552.xka92b8d2cg0s0og-nzlynne@webmail.spamcop.net> <4B6FC97B.80001@gnu.org> <20100208035819.wntyq01vokoc0s4g-nzlynne@webmail.spamcop.net> <4B6FD453.2050400@gnu.org> <20100208201720.5z8d1q6tqg4kgokg-nzlynne@webmail.spamcop.net>
I'm adding autoconf@gnu.org to the destinations, since this is a
pretty fundamental problem with AC_CHECK_DECL and C++
On Tue, Feb 9, 2010 at 02:17, Joern Rennecke
<joern.rennecke@embecosm.com> wrote:
>
>> On 02/08/2010 09:58 AM, Joern Rennecke wrote:
>>>
>>> That would only work if every program that uses libiberty uses
>>> AC_SYSTEM_EXTENSIONS .
>>
>> GCC does, gdb (I think, I don't have it checked out) does and nothing
>> else uses basename anyway (they use lbasename). ?If problems come up,
>> other users can be patched to use AC_USE_SYSTEM_EXTENSIONS.
>
> I've tried going down that route, and it turned out that my original patch
> only
> worked due to a typo. ?The _GNU_SOURCE inconsistency is a red herring.
>
> The real problem is that when libcpp is configured, it is configured with
> g++
> as the compiler, and the test for a basename declaration fails because
> basename is declared in an overloaded way - a const and a non-const
> variant - while the test code has:
> | int
> | main ()
> | {
> | #ifndef basename
> | ? (void) basename;
> | #endif
> |
> | ? ;
> | ? return 0;
> | }
>
> so g++ complains:
>
> conftest.cpp: In function 'int main()':
> conftest.cpp:78:10: error: void cast cannot resolve address of overloaded
> function
>
> and configure mistakenly assumes that no basename declaration exists.
> Thus, when libiberty is included, it 'helpfully' provides another
> declaration
> for basename, which makes the build fail.
>
> So, AC_CHECK_DECLS as it is now simply cannot work when configuring with
> g++ as compiler for any function that has overloaded declarations. ?In
> order to do a valid positive check, we'd have to use a valid function
> signature - which means we have to know a valid function signature first,
> which would be specific to the function.
>
> If we know such a signature, we can use #ifdef __cplusplus to compile
> a function call in this case. ?A C++ compiler should give an error if
> the function was not declared.
>
> We could soup up AC_CHECK_DECLS to know all the standard functions by name,
> or at least the overloaded ones - but I'm not sure such a complex solution
> will really save time in the long term.
Paolo