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: Passing Variable Numbers of Arguments Summary: yet another possible m4 solution Message-ID: <7629@aspect.UUCP> Date: 14 Feb 91 02:10:13 GMT References: <5196@media-lab.MEDIA.MIT.EDU> Organization: Aspect Telecommunications, San Jose, Ca Lines: 31 In article <5196@media-lab.MEDIA.MIT.EDU>, dyoung@media-lab.MEDIA.MIT.EDU (David Young) writes: > > What I'd like is something that could transform a call like: > > PringMsg( window, formatString, ) > > into the following chunk of code: > > { > sprintf( globalFoo, formatString, ); > BlahBlah( window, globalFoo); > } > run this through m4 --------------------8<-------------------------- define(PringMsg,` { sprintf(globalFoo, $2, shift(shift($*))); BlahBlah($1, globalFoo); }') PringMsg( window, formatString, f,o,rm,at,Ar,gs) PringMsg( window, formatString, form,at,Args) --------------------8<-------------------------- CAVEAT: you cannot have commas in formatString -- David Corcoran -@@ uunet!aspect!dave ~ In a society where anything goes eventually everything will.