gpt4 book ai didi

我可以在开关 block 中包含一个开关 block 吗?

转载 作者:太空宇宙 更新时间:2023-11-04 02:02:59 24 4
gpt4 key购买 nike

我在 8051 项目上使用 Keil C,我收到错误 C175 - 来自以下内容的重复大小写值:

switch (x) 
{
case 0:
break;
case 1:
break;
case 2:
switch (y)
{
case 0:
break;
case 1:
break;
}
}

有什么想法吗?

最佳答案

你的编译器坏了。 Keil 因其糟糕的标准合规性而臭名昭著。

C11 6.8.4.2/3

The expression of each case label shall be an integer constant expression and no two of the case constant expressions in the same switch statement shall have the same value after conversion. There may be at most one default label in a switch statement. (Any enclosed switch statement may have a default label or case constant expressions with values that duplicate case constant expressions in the enclosing switch statement.)

上面粗体的规范文本存在于任何版本的 C 标准中。

关于我可以在开关 block 中包含一个开关 block 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24406551/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com