ANSI C语法? [英] ANSI C syntax ?
问题描述
嗨
此代码是否满足ANSI C语法?
void function(void)
{
int a = 2;
a =({int c; c = a + 2;}); / *<< - 这里!! * /
printf(" a =%d \ n",a);
}
谢谢!
tyyoshi
bz ** **@hotmail.com 写道:
嗨
此代码是否满足ANSI C语法?
无效功能(无效)
{
int a = 2;
a =({int c; c = a + 2;}); / *<< - 这里!! * /
printf(" a =%d \ n",a);
}
否。它是否有效C99。你不能在
表达式上下文中放置一个语句块。
bz **** @ hotmail.com 说:
嗨
此代码是否满足ANSI C语法?
void函数(无效)
{
int a = 2;
a =({int c; c = a + 2;}); / *<< - 这里!! * /
否。赋值运算符的右操作数必须(最终)是一个产生值的
表达式。复合语句不会产生
值。
-
Richard Heathfield
" ; Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
电子邮件:rjh在上述域名中, - www。
3月10日下午2:06,santosh ; < santosh .... @ gmail.comwrote:
bz8 ... @ hotmail.com写道:
Hi
此代码是否满足ANSI C语法?
void function(void)
{
int a = 2;
a =({int c; c = a + 2;}); / *<< - 这里!! * /
printf(" a =%d \ n",a);
}
否。它是否有效C99。你不能在
表达式上下文中放置一个语句块。
即使我确实认为它对抗Ansi C标准的复合
语句也不会产生任何价值。但是当我编译它时,它会很好地编译
并执行以得到4的结果。
我正在使用Dev-CPP编译器而我正在使用Windows OS。我''我很惊讶
发现虽然我预计会出现错误,但甚至都没有警告。
这是编译器的错误吗?
Hi
Does this code satisfy ANSI C syntax ?
void function(void)
{
int a = 2;
a = ({int c; c = a + 2;}); /* <<-- here !! */
printf("a=%d\n", a);
}
Thanks !
tsuyoshi
bz****@hotmail.com wrote:Hi
Does this code satisfy ANSI C syntax ?
void function(void)
{
int a = 2;
a = ({int c; c = a + 2;}); /* <<-- here !! */
printf("a=%d\n", a);
}No. Neither is it valid C99. You can''t put a statement block within an
expression context.
bz****@hotmail.com said:
Hi
Does this code satisfy ANSI C syntax ?
void function(void)
{
int a = 2;
a = ({int c; c = a + 2;}); /* <<-- here !! */No. The right operand of an assignment-operator must (eventually) be an
expression that yields a value. A compound statement does not yield a
value.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
On Mar 10, 2:06 pm, "santosh" <santosh....@gmail.comwrote:bz8...@hotmail.com wrote:Hi
Does this code satisfy ANSI C syntax ?
void function(void)
{
int a = 2;
a = ({int c; c = a + 2;}); /* <<-- here !! */
printf("a=%d\n", a);
}
No. Neither is it valid C99. You can''t put a statement block within an
expression context.
Even I did think that its against Ansi C standards as compound
statements dont yield any value. But when I compile it it compiles
well and executes to give a result of 4.
I am using Dev-CPP compiler and I am using Windows OS.I''m surprised to
find that not even warnings are generated though I expected an error.
Is it a bug with the compiler?
这篇关于ANSI C语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!