This is the mail archive of the mailing list for the GCC 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: [RFA] Eliminate warnings about snprintf declaration

On Thu, May 12, 2005 at 07:16:34PM +0300, Eli Zaretskii wrote:
> I guess I'm missing something obvious, since I still don't get it.
> Here's the process of getting these declarations as I understand it:
>   . the configure script checks whether asprintf, basename, ffs,
>     etc. are declared on standard headers
>   . it then edits into config.h and adds the appropriate
>     definitions for HAVE_DECL_ASPRINTF, HAVE_DECL_BASENAME, etc.
>   . include/libiberty.h then enables its own declarations for those
>     platforms for which HAVE_DECL_ASPRINTF etc. say there's a need for
>     a declaration
> Is the above correct?  If so, I need to cause two changes, in addition

The above is correct.

> to modifying include/libiberty.h:
>  1) cause the configure script check for declarations of 2 additional
>     functions--snprintf and vsnprintf
>  2) add #undef's for HAVE_DECL_SNPRINTF and HAVE_DECL_VSNPRINTF which
>     will be edited by the configure script
> How do I make these two changes, if not by modifications to
> libiberty/ followed by running Autoconf?  Are you saying
> that I should change gdb/ (or some other configure)
> instead?

That is also correct.

The principle is that any project which uses libiberty, which wants
these definitions, must request them.  Libiberty's config.h is included
by libiberty source files, before they include libiberty.h.  GDB's
config.h is included by GDB source fles before they include
libiberty.h.  So, if GDB needs the prototype, it is GDB's
responsibility to request it.

Basename is an unfortunate example; you can find some discussion of why
on binutils@ over the last few weeks.  That's because it returns a
pointer, so a prototype _must_ be available in order to safely use it.
This problem doesn't apply to *printf.

Daniel Jacobowitz
CodeSourcery, LLC

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