Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!dog.ee.lbl.gov!pasteur!miro.Berkeley.EDU!foote From: foote@miro.Berkeley.EDU (Bill Foote) Newsgroups: comp.lang.c Subject: #define's with variable length argument lists? Message-ID: <9340@pasteur.Berkeley.EDU> Date: 30 Nov 90 02:32:36 GMT Sender: news@pasteur.Berkeley.EDU Reply-To: foote@miro.Berkeley.EDU (Bill Foote) Organization: University of California at Berkeley Lines: 40 I'd like to add some debugging output to programs that use a library I've written, using this hack: : : #defing glorp(a,b,c) _glorp(__FILE__, __LINE__, a, b, c) : : <...> : : glorp(3.1415926, 0x666, "glorp has intelligent error messages!"); : This allows glorp to report from where it was called. That's great, but what if glorp can have a variable-length argument list? I don't think that #define can handle this... Can it? i.e. can I indicate somehow that the last argument is optional? 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. Is there some good way around this? A way that would be invisible to existing applications (with just an appropriate #define or two in the right .h file)? Thanks in advance, Bill Foote INTERNET: foote@miro.berkeley.edu - or - foote@cs.berkeley.edu UUCP: ..!ucbvax!miro!foote@uunet.uu.net