I found some strange syntax while reading linux source code. The container_of macro looks like
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
what confused me is the syntax like ({statement1; statement2;})
I tried some simple code like
int a = {1;2;};
I compiled it with gcc. After running, 'a' seemed to be 2. But it couldn't be compiled with Microsoft VC++. Is this syntax an expanded feature of gcc? If so, how can I get the same effect without gcc expansion, like define multiple statements and return a value by using macro?