By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,453 Members | 3,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,453 IT Pros & Developers. It's quick & easy.

calling a macro with ommitted input parameter?

P: n/a
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.

--
Spiro R. Trikaliotis
http://www.trikaliotis.net/
Nov 14 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.