printf() problem

Guy Harris guy at auspex.auspex.com
Tue May 2 05:57:21 AEST 1989


>My question is if the stack-based method of passing arguments, or the
>order in which the arguments are passed, is part of the C definition.

No, it's not.

>The alternative seems to me to be making all functions that take a
>variable number of arguments non-portable.

No, it's not.

>Is this the case?

No, it's not.

If you use the "stdarg.h" mechanism in the (p)ANS, any (p)ANS-conforming
compiler is obliged to perform whatever magic is necessary to make that
mechanism work.  If you use the "varargs.h" mechanism supported by many
C implementations, the compiler is again supposed to perform whatever
magic is necessary to make that mechanism work.

However, if you take the address of one of the arguments and use it to
step through the argument list yourself, you run the risk of having your
code not work on some implementations - but then, that style of
variable-number-of-arguments function isn't portable.



More information about the Comp.lang.c mailing list