public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* snprintf warnings
@ 2004-11-13 15:44 Eli Zaretskii
  2004-11-16  1:08 ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2004-11-13 15:44 UTC (permalink / raw)
  To: gdb

When I build GDB with DJGPP, GCC whines like so:

    remote.c: In function `remote_xfer_partial':
    remote.c:4920: warning: implicit declaration of function `snprintf'

(I see this warning for other source files as well.)

This happens because DJGPP doesn't have `snprintf' in its library, so
the libiberty version is used.  But there's no prototype for the
libiberty `snprintf' anywhere, thus the warning.  The code seems to be
relying on getting the prototype from stdio.h, but if the library
doesn't have the function, we cannot expect to have the prototype on a
standard header.

What would be the canonical way to fix that?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: snprintf warnings
  2004-11-13 15:44 snprintf warnings Eli Zaretskii
@ 2004-11-16  1:08 ` Andrew Cagney
  2004-11-16  6:56   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2004-11-16  1:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb

Eli Zaretskii wrote:
> When I build GDB with DJGPP, GCC whines like so:
> 
>     remote.c: In function `remote_xfer_partial':
>     remote.c:4920: warning: implicit declaration of function `snprintf'
> 
> (I see this warning for other source files as well.)
> 
> This happens because DJGPP doesn't have `snprintf' in its library, so
> the libiberty version is used.  But there's no prototype for the
> libiberty `snprintf' anywhere, thus the warning.  The code seems to be
> relying on getting the prototype from stdio.h, but if the library
> doesn't have the function, we cannot expect to have the prototype on a
> standard header.
> 
> What would be the canonical way to fix that?

include/libiberty.h, for instance:

> #if !HAVE_DECL_ASPRINTF
> /* Like sprintf but provides a pointer to malloc'd storage, which must
>    be freed by the caller.  */
> 
> extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
> #endif

Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: snprintf warnings
  2004-11-16  1:08 ` Andrew Cagney
@ 2004-11-16  6:56   ` Eli Zaretskii
  2004-11-17 23:08     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2004-11-16  6:56 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb

> Date: Mon, 15 Nov 2004 19:36:45 -0500
> From: Andrew Cagney <cagney@gnu.org>
> Cc: gdb@sources.redhat.com
> 
> include/libiberty.h, for instance:
> 
> > #if !HAVE_DECL_ASPRINTF
> > /* Like sprintf but provides a pointer to malloc'd storage, which must
> >    be freed by the caller.  */
> > 
> > extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
> > #endif

So you are saying that we should add some configury stuff to produce
HAVE_DECL_SNPRINTF, and then add a fragment similar to the above to
libiberty.h that specifies the prototype for snprintf, yes?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: snprintf warnings
  2004-11-16  6:56   ` Eli Zaretskii
@ 2004-11-17 23:08     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2004-11-17 23:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Andrew Cagney, gdb

On Tue, Nov 16, 2004 at 06:53:48AM +0200, Eli Zaretskii wrote:
> > Date: Mon, 15 Nov 2004 19:36:45 -0500
> > From: Andrew Cagney <cagney@gnu.org>
> > Cc: gdb@sources.redhat.com
> > 
> > include/libiberty.h, for instance:
> > 
> > > #if !HAVE_DECL_ASPRINTF
> > > /* Like sprintf but provides a pointer to malloc'd storage, which must
> > >    be freed by the caller.  */
> > > 
> > > extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
> > > #endif
> 
> So you are saying that we should add some configury stuff to produce
> HAVE_DECL_SNPRINTF, and then add a fragment similar to the above to
> libiberty.h that specifies the prototype for snprintf, yes?

Yes, that sounds like a good idea.

-- 
Daniel Jacobowitz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-17 23:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-13 15:44 snprintf warnings Eli Zaretskii
2004-11-16  1:08 ` Andrew Cagney
2004-11-16  6:56   ` Eli Zaretskii
2004-11-17 23:08     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).