Re: [RFA] Eliminate warnings about snprintf declaration

Daniel Jacobowitz
2005-05-14T14:12:10Z

On Sat, May 14, 2005 at 01:05:51PM +0300, Eli Zaretskii wrote:
> > Date: Thu, 12 May 2005 16:51:03 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: gcc-patches@gcc.gnu.org, gdb-patches@sources.redhat.com
> >
> > > So I need to add these functions to gdb/configure.ac _and_ to
> > > libiberty/configure.ac; got it. I will post a revised patch soon.
> > >
> > > Thanks for your patience.
> >
> > Almost - you don't actually need them in libiberty/configure.ac, unless
> > you see warnings about them during the build of libiberty. To make GDB
> > -Werror happy, all you need is gdb/configure.ac and
> > include/libiberty.h.
>
> Actually, I found that a simpler patch to include/libiberty.h (below)
> is all that is needed to fix all the warnings about snprintf and
> vsnprintf. libiberty.h already does that for asprintf and vasprintf,
> so I think we can use the same method for snprintf and vsnprintf; no
> need to change any configure.ac files.
>
> Okay?
>
> 2005-05-14 Eli Zaretskii <eliz@gnu.org>
>
> * libiberty.h: (snprintf) [!HAVE_DECL_SNPRINTF]: Declare if
> needed.
> (vsnprintf) [!HAVE_DECL_VSNPRINTF]: Declare if needed.

Note that this will only work if there are no systems which declare
snprintf with an incorrect prototype. For instance, a missing const on
the format string in a system header would now generate an error. For
asprintf this isn't an issue, because it's not a standard function;
it's only provided by glibc.

I don't know whether that's a real problem though. I'll let DJ answer
that :-)

--
Daniel Jacobowitz
CodeSourcery, LLC