"Jim Langston" <ta*******@rock etmail.com> wrote in message
news:oE******** *****@fe06.lga. ..
: "param" <dh******@gmail .com> wrote in message
: news:11******** ************@o1 3g2000cwo.googl egroups.com...
: > Hi,
: >
: > I need to write a MACRO which helps to call different functions
: > depending upon it's value say On or OFF. If its' value is ON the
: > function1 should get called and if value is OFF function2 gets called
..
: >
: > It's like same as assert gets executed when NDEBUG is not defined at
: > the start of code. If NDEBUG is defined assert doesn't gets called at
: > all.
: >
: > Thanks
: > dhesi
:
: #define RUNTEST
:
: #ifdef RUNTEST
: #define Func(x) MyFunc(x)
: #else
: #define Func(x) {}
The latter won't work properly with code such as:
if(test)
Func();
else
OtherStuff();
A classic 'no-op' function macro substitution is:
#define Func(x) ((void)0)
[ or the more general: do{ /*whatever*/ }while(0) ]
: #endif
:
: Truth be told, however, you should avoid uses of macros whenever
possible.
Yes!
Regards,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form