#define DEBUG... (using printf for debugging)

Ray Wallace wallace at oldtmr.enet.dec.com
Fri May 4 06:22:25 AEST 1990


In article <4247 at tekfdi.FDI.TEK.COM>, wallyk at tekfdi.FDI.TEK.COM (Wally Kramer)
writes...
>In article <40628 at cornell.UUCP> gordon at cs.cornell.edu (Jeffrey Adam Gordon)
>writes:
>>I want to have a DEBUG flag which controls whether diagnostic printfs
>>are executed or not.
>	DEBUG (("informative message #1: j = %d, k = %d", j, k));
>		/* note extra parens surrounding normal printf parameters */
Why not just do this -

#define	BITCH				/* IE: don't print it */
#define	DEBUG printf			/* IE: do print it */
main( )
{
  BITCH( "What the <%s> is going on?\n", "hell" );
  DEBUG( "%d - nothing.\n%d - something.\n", 1, 2 );
}
When the "debug" macro is defined as nothing then the stuff in paranthesis
gets eveluated as an expresion(s) but thats all. When the "debug" macro is
defined as printf then your standard function call to printf occurs. There is
no need for an extra set of parenthesis.

---
Ray Wallace		
		(INTERNET,UUCP) wallace at oldtmr.enet.dec.com
		(UUCP)		...!decwrl!oldtmr.enet!wallace
		(INTERNET)	wallace%oldtmr.enet at decwrl.dec.com
---



More information about the Comp.lang.c mailing list