Variable number of arguments
Dave Corcoran
dave at aspect.UUCP
Tue May 21 02:01:34 AEST 1991
In article <1991May13.210257.20240 at cunixf.cc.columbia.edu>, ta-dw30 at cunixa.cc.columbia.edu (David Worenklein) writes:
> I know I can pull a variable number of arguments off of the stack using va_...
> but how do I know how many arguments are there? Is there any way to get the
> C compiler to push all the arguments and then push the number of (arguments,
> Thanks.
Email bounced so...
m4 can help if you want to pass the argument count as the first argument
run this through m4 (/usr/5bin/m4 if BSD):
--------------------8<--------------------
define(`numarg_',`$#,$*')
func(numarg_(asdf,qwer,wqer,s,dfa,fdsa,qwre,sdfa,f,qwer,ewrq,sfd))
func(numarg_(asdf,asd,f))
func(numarg_(qwer,"qwer asfd",&asdf,*vzxc))
func(numarg_("caveat:,commas,in,quotes,are,computed,in,count"))
--------------------8<--------------------
--
David Corcoran -@@
uunet!aspect!dave ~
Having the right to do something is not the same as being right in doing it.
-- C.K. Chesterson
More information about the Comp.lang.c
mailing list