Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!uunet!aspect!dave From: dave@aspect.UUCP (Dave Corcoran) Newsgroups: comp.lang.c Subject: Re: Variable number of arguments Summary: suggestion,m4 Message-ID: <10114@aspect.UUCP> Date: 20 May 91 16:01:34 GMT References: <1991May13.210257.20240@cunixf.cc.columbia.edu> Organization: Aspect Telecommunications, San Jose, Ca Lines: 23 In article <1991May13.210257.20240@cunixf.cc.columbia.edu>, ta-dw30@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