是什么&QUOT的目的;(无效)({code})QUOT;在C? [英] what is the purpose of "(void) ( { CODE } )" in c?
问题描述
在C code的产生一块,我发现这样的事情(编辑):
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;
}
我相信,我从来没有见过的构造(无效)({code})
之前,我也不是能找出的目的可能是。
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?
推荐答案
{}
是 GCC
扩展名为语句前pression 的
http://gcc.gnu.org/onlinedocs/gcc/Statement- Exprs.html
一个声明前pression产生一个值,(无效)
投可能是这里删除编译器警告或作出明确的声明价值前pression不被使用。
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.
这篇关于是什么&QUOT的目的;(无效)({code})QUOT;在C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!