This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: selective function call
- From: Brian Dessent <brian at dessent dot net>
- To: Hayim Shaul <hayim at iportent dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 29 Nov 2005 02:23:40 -0800
- Subject: Re: selective function call
- References: <1133259230.3169.10.camel@localhost.localdomain>
Hayim Shaul wrote:
> But this is very tiring.
> I created a MACRO
>
> #define LOG if (logger->is_activated()) logger->print
>
> and use it:
> LOG("%d\n", ackerman(5,5));
How about:
#define LOG(fmt, ...) if (logger->is_activated()) \
logger->print (fmt, ## __VA_ARGS__)
Note that using ## here is a gcc-specific extension that allows for
calling LOG("foo") without following parameters, which would otherwise
cause an error under C99.
Brian