The simplest no-op is just having no code at all:
#define noop
Then user code will have:
if (condition) noop; else do_something();
The alternative that you mention is also a no-op: (void)0;
, but if you are going to use that inside a macro, you should leave the ;
aside for the caller to add:
#define noop (void)0
if (condition) noop; else do_something();
(If ;
was part of the macro, then there would be an extra ;
there)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…