This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] Eliminate warnings about snprintf declaration
> 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.
Index: include/libiberty.h
===================================================================
RCS file: /cvs/src/src/include/libiberty.h,v
retrieving revision 1.44
diff -u -r1.44 libiberty.h
--- include/libiberty.h 12 May 2005 20:00:35 -0000 1.44
+++ include/libiberty.h 14 May 2005 10:08:37 -0000
@@ -531,6 +531,16 @@
ATTRIBUTE_PRINTF(2,0);
#endif
+#if !HAVE_DECL_SNPRINTF
+/* Like sprintf but prints at most N characters. */
+extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
+#endif
+
+#if !HAVE_DECL_VSNPRINTF
+/* Like vsprintf but prints at most N characters. */
+extern int vsnprintf (char *, size_t, const char *, va_list);
+#endif
+
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
/* Drastically simplified alloca configurator. If we're using GCC,