I know that it is commonly used in macros:
#define MY_MACRO(x) ({ int var = x; /* do stuff */; var; })
...
y = MY_MACRO(43);
But how exactly is it interpreted by the compiler? To my understanding, parentheses in C are used for:
Isolation (of conditions)
Group expressions (for precedence)
Function indication
Casting
I don't understand how any of the above is applied here on the scope block but apparently it does the "magic":
#include <stdio.h>
int main(void)
{
int a;
// a = {3}; // --> compilation error "expected expression before '{' token"
// a = {3;}; // --> Same error
a = ({3;}); // --> all is good!
a = ({0; 1; 2; 3;}); // --> warnings for unused values but still, all is good!
printf("a=%d\n", a); // prints a=3
return 0;
}