ISO / IEC 9899 6.8.4.2-> 2短语是什么意思? [英] What does the ISO/IEC 9899 6.8.4.2 ->2 phrase mean?

查看:77
本文介绍了ISO / IEC 9899 6.8.4.2-> 2短语是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白这是什么意思。
我已经认为这可能意味着代码,如我在此问题的代码段中所示:

I don't get it what this means. I already thought this could mean code as in my code snippet of this Question:

通过false循环跳过切换案例是否有效?

但是作为回答者,他们只是在哪里改进代码而忽略了我对c99报价的问题,我现在要在这里明确地问这个问题:

But as the answerers just where going to improve the code and ignored my question about the c99 quote, I'm going to ask this here now explicitly:


如果switch语句在
标识符范围内具有关联的大小写或默认标签,且标识符的类型可变,则整个switch语句应在该标识符的
范围内。 135)

If a switch statement has an associated case or default label within the scope of an identifier with a variably modified type, the entire switch statement shall be within the scope of that identifier.135)

这是脚注:


135)也就是说,声明要么在switch语句之前,要么在最后一个case或
默认标签之后,该标签与包含声明的块中的开关关联。

135) That is, the declaration either precedes the switch statement, or it follows the last case or default label associated with the switch that is in the block containing the declaration.

有人能这么友好地用我的话来解释吗?
感谢您的努力。

could any one be so kindly and explain it to me in other words? Thanks for the effort.

推荐答案

首先请注意,此语句仅适用于可变修改类型的标识符,即在描述中某处具有动态数组维的类型。对于 n 变量,例如

First note that this sentence applies only for identifiers of variably modified type, that is a type that has a dynamic array dimension somewhere in its description. For n a variable something like

double a[n];
unsigned (*B)[n][n];

与这种标识符关联的对象的生存时间有一个特殊的规则,只有

The objects that are associated to this kind of identifier have a special rule for their life time, it only starts at the point of declaration, whereas for other types it starts at entering the scope.

您引用的段落是确保所有 switch 语句的> case 根据该对象的生存时间具有相同的属性。在任何情况下,对象的生命已经开始,或者仅在任何情况(或默认)标签。

The paragraph that you are citing is to ensure that all the case of the switch statement has the same property according to that life time on such an object. Either the life of the object has already started, before any of the cases, or it only starts after any of the case (or default) labels.

因此从本质上讲,这仅表示您不应该混合使用VLA(或类似内容)和跳转语句,因为您不能知道大小是多少,必须在哪里分配数组的内存(如果有)。

So in essence it just indicates that you shouldn't mix usage of VLA (or similar) and jump statements, because you can't know what the size is to be and where the memory for the array (if any) has to be allocated.

这篇关于ISO / IEC 9899 6.8.4.2-> 2短语是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆