Kui*_*ang 5 c macros gcc c-preprocessor
在阅读http://en.wikipedia.org/wiki/C_preprocessor#Multiple_evaluation_of_side_effects时,我遇到了这个例子:
\#define max(a,b) \
({ typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; }) // WHY DOES THIS LINE WORK?
Run Code Online (Sandbox Code Playgroud)
你可以像函数一样使用它,即max(1,2)是一个评估为2的表达式.
我的问题是,构造如何({ statment-list last-expression; })评估last-expression的值?具体来说,这个结构的解析树是什么样的?我认为{ }总是意味着复合语句,而且语句没有值.我试着在C语法中挖掘,仍然无法解决这个问题.