lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) (05/12/88)
In article <2855@phoenix.Princeton.EDU>, lgy@pupthy2.PRINCETON.EDU (Larry Yaffe) writes: > > Are there any versions of cpp which allow one to define macros which > accept variable numbers of arguments? I keep wishing for this every time > I try to move code developed using sysV sprintf to a BSD system, so that > I could do something like: > examples deleted This question comes up now and then. No version of cpp I know has a variable count capability, but those are only AT&T cpp's. You can work around it though, so this is portable. Define a macro like this: #define SPRINTF(args) sprintf args and use it like this: SPRINTF((str, format, a1, a2, ..., an)); The double parens trick cpp into seeing only one argument. After cpp expansion you get: sprintf (str, format, a1, a2, ..., an); -- Larry Cipriani, AT&T Network Systems and Ohio State University Domain: lvc@tut.cis.ohio-state.edu Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (weird but right)