[Top][All Lists]

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

Re: AC_CHECK_DECLS(basename) (Was: Re: Ping: patches required for --ena

From: Paolo Bonzini
Subject: Re: AC_CHECK_DECLS(basename) (Was: Re: Ping: patches required for --enable-build-with-cxx)
Date: Tue, 9 Feb 2010 10:15:03 +0100

I'm adding address@hidden 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
<address@hidden> wrote:
>> On 02/08/2010 09:58 AM, Joern Rennecke wrote:
>>> That would only work if every program that uses libiberty uses
>> 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.


reply via email to

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