Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!grebyn!ckp From: ckp@grebyn.com (Checkpoint Technologies) Newsgroups: comp.lang.c Subject: Re: #define's with variable length argument lists? Message-ID: <23670@grebyn.com> Date: 30 Nov 90 05:58:00 GMT References: <9340@pasteur.Berkeley.EDU> Reply-To: ckp@grebyn.UUCP (Checkpoint Technologies) Organization: Grebyn Timesharing, Vienna, VA, USA Lines: 27 In article <9340@pasteur.Berkeley.EDU> foote@miro.Berkeley.EDU (Bill Foote) writes: >: #define glorp(a,b,c) _glorp(__FILE__, __LINE__, a, b, c) >: glorp(3.1415926, 0x666, "glorp has intelligent error messages!"); > >That's great, but what if glorp can have a variable-length argument list? >I know that I could do the following: >: #define glorp(a) { _set_error(__FILE__, __LINE__); \ >: _glorp a } >: glorp((27, "This is ugly!")); >but this is inefficient, ugly, and breaks all of my existing applications. Just off the top of my head... This may work for you. : #define glorp _set_error(__FILE__,__LINE__), _glorp The macro definition specifies _no_ parameters. Specifically, whatever parenthesised expression you code following a call to glorp is not considered part of the macro expansion, but will simply appear as the parameters to the enclosed trailing call to _glorp. -- First comes the logo: C H E C K P O I N T T E C H N O L O G I E S / / \\ / / Then, the disclaimer: All expressed opinions are, indeed, opinions. \ / o Now for the witty part: I'm pink, therefore, I'm spam! \/