This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: libiberty requirements and ISO C90
- 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: 15 May 2005 23:20:14 -0400
- Subject: Re: libiberty requirements and ISO C90
- References: <m3is1ju8yi.fsf@uniton.integrable-solutions.net>
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> The file libiberty/xstrerror.c contains the following fragment
>
> #ifdef VMS
> #include <errno.h>
> #if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
> extern char *strerror (int,...);
> #define DONT_DECLARE_STRERROR
> #endif
> #endif /* VMS */
>
> #ifndef DONT_DECLARE_STRERROR
> extern char *strerror (int);
> #endif
...
> Do you agree that the declaration could safely be replaced with a
> #include <string.h>?
Well, we require an ISO C90 compiler; do we require ISO C90 libraries?
If we require the libraries, then we can remove a number of files from
libiberty, at least atexit.c, memchr.c, memcmp.c, memcpy.c, memmove.c,
memset.c, snprintf.c, strchr.c, strerror.c, strncmp.c, strrchr.c,
strtol.c, strtoul.c, vfprintf.c, vsprintf.c. If we don't require the
libraries, then we can't assume that <string.h> declares strerror. In
fact, technically we can't even assume that <string.h> exists,
although we do currently have a few cases where it is included without
being protected by #ifdef HAVE_STRING_H.
I think the more conservative approach would be to simply add strerror
to AC_CHECK_DECLS, include <string.h> in xstrerror.c (protected by
HAVE_STRING_H), and protect the strerror declaration with
#if !HAVE_DECL_STRERROR
Ian