Statements in Expressions

When the GCC extensions setting is on, expressions in function bodies may contain statements and definitions. To use a statement or declaration in an expression, enclose it within braces. The last item in the brace-enclosed expression gives the expression its value. The following listing shows an example.

Listing: Using Statements and Definitions in Expressions
#define POW2(n) ({ int i,r; for(r=1,i=n; i>0; --i) r *= 2; r;}) 
int main() 
{ 
    return POW2(4); 
}