Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!crdgw1!sixhub!davidsen From: davidsen@sixhub.UUCP (Wm E. Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: Variable Parameters Message-ID: <366@sixhub.UUCP> Date: 1 Jan 90 18:53:36 GMT References: <1169@zip.eecs.umich.edu> <1989Dec31.013746.2349@utzoo.uucp> <363@sixhub.UUCP> <1990Jan1.004914.25006@utzoo.uucp> Reply-To: davidsen@sixhub.UUCP (bill davidsen) Organization: *IX Public Access UNIX, Schenectady NY Lines: 26 In article <1990Jan1.004914.25006@utzoo.uucp> henry@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@sixhub.uucp ...!uunet!crdgw1!sixhub!davidsen "Getting old is bad, but it beats the hell out of the alternative" -anon