Serve Laurijssen said:
The following code compiles on 2 compilers here:
#define X(a) ((a)+10)
int main(void)
{
int X = 2;
return 0;
}
but if X is defined as #define X (2)
then this code doesnt compile anymore?
Is that according to standard ?
Yes. #define X(a) ((a)+10) defines a function-like macro. To invoke a
function-like macro, you'd have to say something like X(arg), complete with
parenthesised argument - not just X on its own. So your example program
simply defines an int called X, which is obviously legal; it doesn't invoke
your macro at all.
#define X (2) doesn't define a function-like macro. If you were to change
your program in this way, it would expand to:
int main(void)
{
int (2) = 2;
return 0;
}
which is obviously illegal.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.