Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] common-defs.h: include <stdarg.h> before <stdio.h>
@ 2014-11-14 16:48 Joel Brobecker
  2014-11-14 16:54 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2014-11-14 16:48 UTC (permalink / raw)
  To: gdb-patches

When trying to build gdbserver on ppc-lynx178, the compiler reports
while trying to compile gdbserver/ax.c that vsprintf is not declared.
Looking at my C99 reference manual (a draft), I see the following
synopsis:

    #include <stdarg.h>
    #include <stdio.h>
    int vsprintf(char * restrict s, [etc]);

Looking at stdio.h on LynxOS-178, if found where vsprintf gets
declared:

    #if defined(__varargs_h) || defined(__stdarg_h) \
            || defined(_VARARGS_H) || defined(_STDARG_H)
    extern int vsprintf             _AP((char *, const char *, va_list));
    #endif

Digging further, I noticed that common-defs.h, which is included
via server.h, includes stdarg.h after including stdio, explaining
why vsprintf does not get declared in this case.

This patch fixes the problem by including stdarg.h before stdio.h.

gdb/ChangeLog:

        * common/common-defs.h: Move <stdarg.h> #include ahead of
        <stdio.h> #include.

Tested on x86_64-linux. This was also implicitly tested on all
the platforms that we build GDB & GDBserver on, and no problem
has been detected since we made that change (Oct 6th).

OK to commit?

Thanks,
-- 
Joel

---
 gdb/common/common-defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 29c8ab3..4d2e8a7 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -27,9 +27,9 @@
 #include "build-gnulib/config.h"
 #endif
 
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
 #include <stddef.h>
 #include <string.h>
 #include <errno.h>
-- 
1.9.1


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

* Re: [RFA] common-defs.h: include <stdarg.h> before <stdio.h>
  2014-11-14 16:48 [RFA] common-defs.h: include <stdarg.h> before <stdio.h> Joel Brobecker
@ 2014-11-14 16:54 ` Pedro Alves
  2014-11-14 17:02   ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2014-11-14 16:54 UTC (permalink / raw)
  To: Joel Brobecker, gdb-patches

On 11/14/2014 04:48 PM, Joel Brobecker wrote:
> When trying to build gdbserver on ppc-lynx178, the compiler reports
> while trying to compile gdbserver/ax.c that vsprintf is not declared.
> Looking at my C99 reference manual (a draft), I see the following
> synopsis:
> 
>     #include <stdarg.h>
>     #include <stdio.h>
>     int vsprintf(char * restrict s, [etc]);

This says the same:

 http://pubs.opengroup.org/onlinepubs/009695399/functions/vfprintf.html

> OK to commit?

Definitely.

Thanks,
Pedro Alves


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

* Re: [RFA] common-defs.h: include <stdarg.h> before <stdio.h>
  2014-11-14 16:54 ` Pedro Alves
@ 2014-11-14 17:02   ` Joel Brobecker
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2014-11-14 17:02 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

> > When trying to build gdbserver on ppc-lynx178, the compiler reports
> > while trying to compile gdbserver/ax.c that vsprintf is not declared.
> > Looking at my C99 reference manual (a draft), I see the following
> > synopsis:
> > 
> >     #include <stdarg.h>
> >     #include <stdio.h>
> >     int vsprintf(char * restrict s, [etc]);
> 
> This says the same:
> 
>  http://pubs.opengroup.org/onlinepubs/009695399/functions/vfprintf.html
> 
> > OK to commit?
> 
> Definitely.

Thank you, Pedro. Now pushed.

-- 
Joel


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

end of thread, other threads:[~2014-11-14 17:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-14 16:48 [RFA] common-defs.h: include <stdarg.h> before <stdio.h> Joel Brobecker
2014-11-14 16:54 ` Pedro Alves
2014-11-14 17:02   ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox