(void)0的理解

来源:互联网 发布:华为没有网络怎么回事 编辑:程序博客网 时间:2024/06/02 13:29
  1. (void)0 (+;) is a valid, but 'does-nothing' C++ expression, that's everything. It doesn't translate to the no-op instruction of the target architecture, it's just an empty statement as placeholder whenever the language expects a complete statement (for example as target for a jump label, or in the body of an if clause).

  2. You should note that, used as a macro (say, #define noop (void)0), the (void) prevents it from being accidentally used as a value (as in int x = noop.

    详细解释可参看:Why is (void) 0 a no operation in C and C++?

0 0