21

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.

Community
  • 1
  • 1
enobayram
  • 4,650
  • 23
  • 36

1 Answers1

27

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

cnicutar
  • 178,505
  • 25
  • 365
  • 392