S
Srinivas Mudireddy
Hi,
I am facing a problem with trying to conditionally compile inside a
macro. I have a macro
#define SET_VAL(x, y) ((x) = *(y))
But the problem is y can be NULL in which case I want to set x to 0. So
I modified macro to
#define SET_VAL(x, y)
#if y == NULL
x = 0;
#else
(x) = *(y);
#endif
This is not working since # has a special meaning inside a macro. Is
there any way I can get around this problem with still using a macro? I
can define a function to do the same, but I would prefer to use a
macro.
Thanks,
Srinivas
I am facing a problem with trying to conditionally compile inside a
macro. I have a macro
#define SET_VAL(x, y) ((x) = *(y))
But the problem is y can be NULL in which case I want to set x to 0. So
I modified macro to
#define SET_VAL(x, y)
#if y == NULL
x = 0;
#else
(x) = *(y);
#endif
This is not working since # has a special meaning inside a macro. Is
there any way I can get around this problem with still using a macro? I
can define a function to do the same, but I would prefer to use a
macro.
Thanks,
Srinivas