More information on `({});` in C?

后端 未结 3 1185
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 00:58

I\'ve noticed that sometimes, C macros are written as something like this:

#define foo(bar) ({ ++bar; })

After some experimentation, I\'ve

3条回答
  •  清酒与你
    2021-01-18 01:52

    () is an expression. ({code; code;}) is a compound statement inside an expression. That is a GNU C extension.

    http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html

    EDIT: wow, I got that link from Google and didn't notice it was for gcc 2.95 at first. Ancient!

提交回复
热议问题