help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Eliminate Function Call in Conditional Macro


From: PORTER, JAMES C (Jim), ALBAS
Subject: RE: Eliminate Function Call in Conditional Macro
Date: Tue, 13 Aug 2002 08:00:25 -0400

This is from the IBM Open Class Library, which is trying to do the same 
technique...

#ifdef IC_TRACE_RUNTIME
   #define ITRACE_RUNTIME(p1)          ITrace::write(p1)
#else
   #define ITRACE_RUNTIME(p1)
#endif

The difference is -- you need to include the parameter in the #define variable, 
so that the parameter is part of the definition.

Jim          iGEMS Architect and NC3 Development
                  AT&T Labs / GBS Development, Boulder CO 
                  303-684-9016     jcporter@att.com 


-----Original Message-----
From: Shigeru Mabuchi [mailto:mab@wing.gr.jp]
Sent: Tuesday, August 13, 2002 2:34 AM
To: help-gplusplus@gnu.org
Subject: Eliminate Function Call in Conditional Macro



Hello, I'm new to this mailing list.

I use the following macro in my Visual C source codes.

#ifdef _TRACE
#define TRACE  Trace
#else
#define TRACE ((void)0)
#endif

 where I have a Trace(const char* format,...) function
defined. A line likes

  TRACE("Counter is %n\n",counter);

 will work in debug codes, and this line itself will
be eliminated in the release codes.

 I transport this codes to gcc (2.95) but the (void)0
gives me an error when _TRACE is not defined: 

 'void value not ignored as it ought to be'

 Is there any way to do this on gcc?

 Thanks.

S. Mabuchi
WING
http://www.wing.gr.jp/





_______________________________________________
Help-gplusplus mailing list
Help-gplusplus@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gplusplus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]