Variable argument lists.

Peter J Desnoyers peter at athena.mit.edu
Thu May 12 03:39:13 AEST 1988


In article <11435 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>In article <14139 at brl-adm.ARPA> bates%falcon.dnet%fermat at bru.mayo.edu
>(Cary Bates) writes:
>>In VAX C [by which I presume he means some version of VMS C] there
>>is a macro called va_count.
>I would bet that it does not work.  Try:
>	int f(int x, ...) { return va_count(); }
>	int main() {
>		printf("%d\n", f(0, (double)0, (double)0));
>		return 0;
>	}
>In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
>Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris

As pointed out, it is VAXC, not VMS C. The VAX explicitly saves a lot
of information on the stack when it makes a subroutine call, and argument
list length is one of them. The issue of arguments of different
lengths is a tricky one - if 'f' pulls arguments off the stack as ints,
then 5 is the correct value, since that is the number it will see. If it
pulls them off as doubles, then the call is incorrect, and va_count might
not be well defined. If it is a printf-like function, then god knows
what happens. (I wish I could check my manual, but I have the 1982 version.)

.
.
.
				Peter Desnoyers
				peter at athena.mit.edu



More information about the Comp.lang.c mailing list