[comp.lang.c] Varargs implementation

blarson@skat.usc.edu (Bob Larson) (10/27/88)

In article <23385@amdcad.AMD.COM> tim@crackle.amd.com (Tim Olson) writes:
>How do you suppose varargs functions are implemented?  

In whatever machine/os/compiler specific way that is handy.

>They must take
>the address of the first parameter to "step through" the parameter list.

"must"?  I've written a couple of varargs implementations, and banged on
another.  I don't seem to recall any such requirement in the varargs specs,
and in fact that is not how I did it on the one I wrote for a system that
does pass the first two (with exceptions) arguments in registers.  Maybe
some do it that way, but that does not imply that that is the only way.

>Are you suggesting that varargs functions are not portable and should be
>avoided?

That was not my assertion, but note that ANSI decided vararg.h wasn't
portable enough so came up with stdarg.h.  (The compiler I mentioned
above would need internal support for stdarg.h while vararg.h can be added
as an afterthought.  Is this increased portability?)
-- 
Bob Larson	Arpa: Blarson@Ecla.Usc.Edu	blarson@skat.usc.edu
Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson
Prime mailing list:	info-prime-request%ais1@ecla.usc.edu
			oberon!ais1!info-prime-request