Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!asuvax!ncar!mephisto!gatech!galbp!samna!jeff From: jeff@samna.UUCP (jeff) Newsgroups: comp.lang.c Subject: Re: Commas in macro arguments Message-ID: <246@samna.UUCP> Date: 28 Mar 90 21:26:59 GMT References: <1990Mar22.203048.18491@dde.dk> <1990Mar23.164301.14975@utzoo.uucp> Reply-To: jeff@samna.UUCP () Organization: Draughtsman's Contractors Lines: 33 In article peter@ficc.uu.net (Peter da Silva) writes: >> >#define call(a,b) a(b) > >> >I can use that to call a function with one argument. How can I use >> >it to call a function with two arguments? > >Sometimes you can, depending on how much you want to munge the arguments: > >#define call(a,b) a b > >call(a,(b)) >call(c,(d,e)) I sometimes use this mechanism to put debugging printf's in source files (Can be used for any variable argument macro). Debugging statements are written like this: DPRINTF(("Variable x=%d, y=%d, z=%d\n", x, y, z)); Then in a header file: #ifdef DEBUG # define DPRINTF(s) printf s #else # define DPRINTF(s) #endif Sometimes it's kinda hard to remember the extra set of parentheses, but... Jeff