Article View: comp.std.c
Article #5348Re: Variable length arg lists for macros
From: Mark Jones
Date: Thu, 08 Sep 1988 16:28
Date: Thu, 08 Sep 1988 16:28
45 lines
1416 bytes
1416 bytes
In article <3604@phoenix.Princeton.EDU>, haahr@phoenix.Princeton.EDU (Paul Gluckauf Haahr) writes:
> > How do people feel about the idea of preprocessor macros with variable
> > length argument lists ?
> >
> > However this can not be done with macro calls. Wouldn't it be nice to be
> > able to do something like ...
> >
> >
> > #ifdef TRACE
> > #define tracef(s,...) printf(s,...)
> > #else
> > #define tracef(s,...) /* nothing */
> > #endif
> >
> > At present, this CANNOT BE DONE, without nesting parentheses (clumsy) or
> > using a call to an empty function (inefficient, unless you have inline
> > integration in an optimizing compiler).
If you want a trace function, try this one
#ifdef TRACE
#define TR(x) x
#else
#define TR(x)
#endif
Now, you can just say
.
.
.
TR(printf("entering buggy function"));
.
.
.
and all is well!
Bought from Dr Dobbs Journal, Only good thing to come out of that
magazine in months.(Did BYTE buy them out?) <-- Rhetorical question
Mark Jones
Technical Details
Message-ID:
<2517@ingr.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!ingr!jonesReferences:
<438@ucsvc.unimelb.edu.au> <3604@phoenix.Princeton.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ingr!jones From: jones@ingr.UUCP (Mark Jones) Newsgroups: comp.std.c Subject: Re: Variable length arg lists for macros Summary: How about this way Message-ID: <2517@ingr.UUCP> Date: 8 Sep 88 16:28:38 GMT References: <438@ucsvc.unimelb.edu.au> <3604@phoenix.Princeton.EDU> Organization: Intergraph Corp. Huntsville, Al Lines: 45