This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: snprintf warnings


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]