Re: need help with variable args prep. macro by Tim
Tim
Sun Jul 13 23:33:17 CDT 2008
"Hendrik Schober" <SpamTrap@gmx.de> wrote:
>Norbert Unterberg <nunterberg@newsgroups.nospam> wrote:
>
>> You could use inline functions instead, or use some kind of workaround with
>> double braces, like:
>>
>> #define PRINTD(format) if (DEBUG) printf format
>>
>> and call it with double braces like this:
>>
>> PRINTD(("%s %d\n", "Hello", 10));
>
> Mhmm. If you use macros anyway, why not define them this
> way
> #define PRINTD if (DEBUG) printf
> so you don't need those extra braces?
OK, but then what do you do for the non-debug case, where you want the
expression to go away?
There are certainly ways to do that:
#define PRINTD 1?0:
but I'm not sure they are quite as elegant.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.