Variable Parameters
Wm E. Davidsen Jr
davidsen at sixhub.UUCP
Tue Jan 2 05:53:36 AEST 1990
In article <1990Jan1.004914.25006 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
| The fundamental problem with finding out how many arguments you have --
| ignoring the problem of varying sizes, which got much worse when C
| acquired struct passing -- is that in general you need cooperation
| from the caller. On some machines, the information can be deduced
| from details of the stack frame or the calling sequence, but on many
| modern systems, it has to be explicitly provided at significant cost.
As I mentioned, the original versions which with I worked in the 70's
did have the caller provide the information, but the cost was only one
word in the call sequence (no CPU overhead). As common as calls are in
C, they are a very small % of the code. Because of the size problems you
mentioned, it is very difficult to deduce the number of arguments from
the call frame, even when the size of the frame can be determined.
Varargs is a workable solution to the problem, and I certainly don't
suggest that there is a better simple one. Having to have both address
and type information for the arguments certainly lends itself to
cumbersome solutions.
--
bill davidsen - sysop *IX BBS and Public Access UNIX
davidsen at sixhub.uucp ...!uunet!crdgw1!sixhub!davidsen
"Getting old is bad, but it beats the hell out of the alternative" -anon
More information about the Comp.lang.c
mailing list