I am looking at some kind of code and I found the following macro:
int foo = 0; (foo);
It compiles just fine. In fact, it seems that
0;
- A valid line of code in C / C ++.
I took a look at assembly assembly in debug and release assemblies (on msvc), and that doesn't make any difference to the assembly. My test was simple though (with and without (foo); ):
int main() { int foo = 0; (foo); return 0; }
My question is, why does anyone want to do this? I am sure (foo); is in the macro for some reason, but I'm not sure why.
For context, the macro found is as follows (I renamed the variables):
#define MY_MACRO int _foo = 0; (_foo); UINT _bar = CP_THREAD_ACP; (_bar); LPCWSTR _baz = NULL; (_baz); LPCSTR _thing = NULL; (_thing)
In code, this is simply called
MY_MACRO;
source share