var args
warren at ihnss.UUCP
warren at ihnss.UUCP
Thu Oct 27 00:59:46 AEST 1983
The technique of declaring a function with the maximum number of
expected arguments and then passing them on:
foo(a1,a2,a3,a4,...an)
char *a1,*a2, ..., *an;
{
error(errno,fmt,a1, ..., an);
DOES NOT work in all implementations. An obvious failure occurs
when the stack isn't big enough to accomodate all of the arguments
that aren't passed to foo. A less obvious problem that I have seen
(I forget exactly which machine it was on) is that the compiler
passes the pointer arguments using "effective address" type
instructions to get the pointer, rather than just copying the bits,
and the machine generates some sort of fault if the address in the
pointer is invalid. Since the junk you pick up on the stack
can to be an invalid address, your code randomly fails depending
on what happens to be on the stack.
--
Warren Montgomery
ihnss!warren
IH x2494
More information about the Comp.lang.c
mailing list