[gccsdk] libscl valist functions and __GNUC__

Nick Burrett nick at sqrt.co.uk
Sun May 27 10:23:51 PDT 2007

On 5/27/07, John Tytgat <John.Tytgat at aaug.net> wrote:
> In message <ab4886070705240114x504a48c5n6246182299847ab5 at mail.gmail.com>
>           "Nick Burrett" <nick at sqrt.co.uk> wrote:
> > The macros were defined in stdio.h.  I wrote them because Norcroft did
> > an extra level of indirection when passing the vararg pointer to the
> > function.  We needed to emulate this within GCC in order to get
> > vsscanf() and friends working.  Certainly this used to work, as I
> > tested it when I originally wrote the macros.
> >
> > The va_list formats are the same, as this is defined by the APCS.
> Is it ? Because the way float arguments are passed is different between
> GCC and Norcroft.  GCC will stick to 4 bytes while Norcroft will convert
> the floats to doubles and reserve 8 bytes for this.
> I never found an authoritive source on the APCS-R or APCS-32 definition
> saying which convention is the right one.

Yes, you're right.  Norcroft promotes float arguments to double
whereas GCC will not.  The convention in GCC is the correct one, but
I'm not sure of the historical reason as to why Norcroft promotes to

> > It is just the passing of the va_list to the function that is different
> > here.
> I don't see in our libscl code a different treatment of va_list passing
> between GCC and Norcroft.

In stdio.h, we have macro definitions like this:

#define vsnprintf(__s,__limit,__fmt,__ap) \
        (__gcc_vsnprintf(__s,__limit,__fmt, &__ap))

> > Note that the use of macros here would suggest that linking with GCC
> > compiled code against any Norcroft library that uses the va_list arg,
> > would result in problems.
> r2 (admin): Added __gcc_vprintf, __gcc_vfprintf and __gcc_vsprintf as
>   aliases for vprintf, vfprintf and vsprintf.
> r878 (nick): Added the __gcc_* macros in stdio.h
> r1639 (alex): Added __gcc_vsnprintf as alias for vsnprintf.
> r2637 (joty): Added __gcc_vfscanf, __gcc_vscanf and __gcc_vsscanf as
>   aliases for vfscanf, vscanf and vsscanf.
> I'm not sure if my change r2637 made today is the best one. I would be
> tempted to remove the __gcc_*() macros and the resulting changes made in
> r2, r1639 and r2637.

This is quite easy to test.  Just write a simple program that calls
vprintf(), remove the macros and see what happens when you link
against the SCL.



More information about the gcc mailing list