Parenthesis operator in C. What is the effect in the following code

Posted by Andre on Stack Overflow See other posts from Stack Overflow or by Andre
Published on 2010-04-13T14:11:08Z Indexed on 2010/04/13 14:13 UTC
Read the original article Hit count: 245

Filed under:
|

Hi everyone,

I was playing with a macro to enable/disable traces when I came out with the following code when the macro is disabled:

int main {

("Hello world");

}

This code is valid and I got the desired effect (nothing happens when the macro is disabled) but I couldn't figure out what exactly is happening. Is the compiler seeing the parenthesis as a "nameless" method declaration?

To make it clearer the code is :

#ifdef TRACE

#define trace printf("%s %d -> ",__FILE__, __LINE__);printf

else

#define trace

#endif

int main {

trace("Hello world");

}

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c

    Related posts about parenthesis