S
Spiro Trikaliotis
Hello,
assume I define a macro like
#if <somecondition>
# define MACRO(_x, _y) _x
#else
# define MACRO(_x, _y) _y
#endif
Now, I call it later with
MACRO(/* no parameter */, ABC)
or
MACRO(ABC, /* no parameter */)
Is this legal in C90 and/or C99? This is, can I ommit parameters to
MACRO by just leaving the contents out?
Some background on why I'm asking this:
I'm using this construction (I'm lazy ;-)) with gcc and the Microsoft
Compiler, and until now, it worked perfectly.
Anyway, just recently, I found out that if I run the Microsoft
Compiler with a special switch ("prefast"), it behaves somehow
"unrationally". To me, it seems that although <somecondition> is true,
it uses the "wrong" macro.
Now, my question is: Is the above legal C? That is, should I expect it
to work, or is the Microsoft Compiler right in behaving unexpectedly, as
my code is outside of the language C?
Many thanks,
Spiro.
assume I define a macro like
#if <somecondition>
# define MACRO(_x, _y) _x
#else
# define MACRO(_x, _y) _y
#endif
Now, I call it later with
MACRO(/* no parameter */, ABC)
or
MACRO(ABC, /* no parameter */)
Is this legal in C90 and/or C99? This is, can I ommit parameters to
MACRO by just leaving the contents out?
Some background on why I'm asking this:
I'm using this construction (I'm lazy ;-)) with gcc and the Microsoft
Compiler, and until now, it worked perfectly.
Anyway, just recently, I found out that if I run the Microsoft
Compiler with a special switch ("prefast"), it behaves somehow
"unrationally". To me, it seems that although <somecondition> is true,
it uses the "wrong" macro.
Now, my question is: Is the above legal C? That is, should I expect it
to work, or is the Microsoft Compiler right in behaving unexpectedly, as
my code is outside of the language C?
Many thanks,
Spiro.