In a generated piece of c code I found something like this (edited):
#include <stdio.h>
int main() {
(void) (
{
int i = 1;
int y = 2;
printf("%d %d\n", i,y);
}
);
return 0;
}
I believe I have never seen the construct (void) ( { CODE } ) before, nor am I able to figure out what the purpose might be.
So, what does this construct do?
({ })is agccextension called a statement expression.http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
A statement expression yields a value and the
(void)cast is probably here to remove the compiler warning or to make explicit that the value of the statement expression is not used.Now
(void) ({ })is the same as a simple compound statement{}and there is no point of using it.