I found this while reading some source code.
#define MACRO(x) if((void) 0, (x)); else some_func();
I don’t fully understand the reasons behind that operator comma and the void cast. This has probably something to do with macro protection, I know that (void)0 is used sometimes to protect cascading elses in macros such as in if(...) then foo(); else (void)0.
Any ideas of why operator comma is there?
edit: I’m starting to think this has something to do with the owl (0,0).
I would guess that the trick is used to prevent the user from declaring variables in the
ifcondition. As you probably know, in C++ it is legal to do thisThe use of comma operator in that definition will prevent macro usage like
and force the user to use only expressions as argument.