Re: selective function call

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

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux