I've noticed that sometimes, C macros are written as something like this:
#define foo(bar) ({ ++bar; })
After some experimentation, I've found that:
({});
will compile, but do nothing. (As expected.)- Leaving the
;
off will cause a syntax error. A side effect of this is ensuring that foo() looks like a function in your code. (Although, if you leave the semicolon off, the error isn't very useful for diagnosing the problem!) return ({});
complains about a void value not being ignored, just like if I had tried to use a void function.
Is this just to make developers add a semicolon to their macros, or does it have another purpose? I've tried Google, but it fails miserably with punctuation. Is there a name for this?