printf() problem
Henry Spencer
henry at utzoo.uucp
Sun Apr 30 10:12:31 AEST 1989
In article <1367 at ndmath.UUCP> dierks at ndmath.UUCP (Tim Dierks) writes:
> I understand that the _order_ of evaluation is undefined... 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. The alternative
>seems to me to be making all functions that take a variable number of
>arguments non-portable. Is this the case?
No definition of C mandates a stack, or any ordering of arguments within
anything. Variadic functions need to use non-portable machinery to pick
up their arguments, although modern practice is to encapsulate said
machinery inside macros with portable interfaces, like <varargs.h> or
<stdarg.h>.
Stacks are actually usually a bad way of passing arguments. Passing at
least the first two or three parameters in registers is often superior.
(Although it complicates <varargs.h> etc., and can break crufty old
programs.)
--
Mars in 1980s: USSR, 2 tries, | Henry Spencer at U of Toronto Zoology
2 failures; USA, 0 tries. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list