This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: libiberty configure mysteries
- From: Ian Lance Taylor <ian at airs dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: gcc at gcc dot gnu dot org, DJ Delorie <dj at redhat dot com>
- Date: 10 Apr 2005 12:00:59 -0400
- Subject: Re: libiberty configure mysteries
- References: <m3fyxyoesz.fsf@uniton.integrable-solutions.net>
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> The following is from libibtery.h
>
> /* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
> undefined, we haven't run the autoconf check so provide the
> declaration without arguments. If it is 0, we checked and failed
> to find the declaration so provide a fully prototyped one. If it
> is 1, we found it so don't provide any declaration at all. */
>
> However, that appears to be incorrect because what configure output in
> config.h is not HAVE_DECL_XXX, but HAVE_XXX. Therefore, it appears
> that libiberty would be misdetecting declarations -- it thinks
> something is missing, whereas in fact it is not.
HAVE_XXX means that the function exists on the system. HAVE_DECL_XXX
means that the function is declared in a header file. The libiberty
configure script itself doesn't bother to test for any declarations.
The tests for HAVE_DECL_XXX in libiberty.h are for the benefit of
other programs which use libiberty.
> The way I ran into this problem is when trying to compile libiberty
> with a C++ compiler, which is quite intolerant about declaration
> mismatches:
>
> /home/gdr/tmp/ipr.gcc-4.1/libiberty/../include/libiberty.h:78: error:
> declaration of 'char* basename(const char*)' throws different exceptions
> /usr/include/string.h:345: error: than previous declaration 'char*
> basename(const char*) throw ()'
>
> Of course, configure #defines HAVE_BASENAME to 1, but libiberty is
> testing for HAVE_DECL_BASENAME.
This approach was designed to work with C compilers, which are more
forgiving. As Daniel said, you will need to add an AC_CHECK_DECLS to
the libiberty configure.ac for basename, and probably for some other
functions as well. Then you will have to return autoconf and
autoheader. Make sure the configure script outputs "whether basename
is declared". Make sure that HAVE_DECL_BASENAME appears in
libiberty/config.in (which is generated by autoheader). Make sure
that every file in libiberty which includes libiberty.h includes
config.h first.
Ian