Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange C/C++ syntax [duplicate]

Tags:

Possible Duplicate:
What's this C++ syntax that puts a brace-surrounded block where an expression is expected?

I've just come across this strange C/C++ syntax:

#include <stdio.h> int main() {     printf("%s",         ({         static char b__[129];         b__[0] = 55;         b__[1] = 55;         b__[2] = 0;         b__;         })     ); } 

This compiles and runs fine using both gcc and g++ (4.5.2). This is the first time I see something like this, and I wonder what exactly this syntax means. I've tried to Google it, but I have no idea what this construct is called.

like image 374
enobayram Avatar asked Feb 24 '12 13:02

enobayram


1 Answers

They're called statement expressions, it's a GNU extension. In your example the result of the expression is b__.

like image 72
cnicutar Avatar answered Oct 14 '22 20:10

cnicutar