initialization of xxx is skipped by xxx
来源:互联网 发布:用手机安装plc编程软件 编辑:程序博客网 时间:2024/05/20 05:53
使用case或goto语句时,有时会碰到如下提示:
vc2008:initialization of xxx is skipped by xxx
gcc:crosses initialization of xxx
以case为例:
codeblocks(gcc) 编译提示:
In function `int main()':
error: jump to case label
error: crosses initialization of `int b'
error: jump to case label|
error: crosses initialization of `int b'
warning: unused variable 'b'
=== Build finished: 4 errors, 1 warnings ===
codeblocks(vc2008) 编译提示:
error C2360: initialization of 'b' is skipped by 'case' label
error C2361: initialization of 'b' is skipped by 'default' label
=== Build finished: 2 errors, 0 warnings ===
问题出在 b 的作用域,b 只在"case 0"的情况下进行了初始化,如果是其他语句就会被跳过去,
vc2008:initialization of xxx is skipped by xxx
gcc:crosses initialization of xxx
以case为例:
int main( void ){ int a = 2; switch (a) { case 0: int b = 0; break; case 1: cout << a << endl;break; default: break; } return 0;}
codeblocks(gcc) 编译提示:
In function `int main()':
error: jump to case label
error: crosses initialization of `int b'
error: jump to case label|
error: crosses initialization of `int b'
warning: unused variable 'b'
=== Build finished: 4 errors, 1 warnings ===
codeblocks(vc2008) 编译提示:
error C2360: initialization of 'b' is skipped by 'case' label
error C2361: initialization of 'b' is skipped by 'default' label
=== Build finished: 2 errors, 0 warnings ===
问题出在 b 的作用域,b 只在"case 0"的情况下进行了初始化,如果是其他语句就会被跳过去,
改变 b 的作用域就可以了,一般使用{}就可以了
... case 0: { int b = 0; } break; ...
- initialization of xxx is skipped by xxx
- initialization of 'XXX' is skipped by 'case' label
- c++ error initialization of "xxx" is skipped by case label
- initialization of 'XXX' is skipped by 'case' label 原因及解决办法
- initialization of 'XXX' is skipped by 'case' label 原因及解决办法
- initialization of 'XXX' is skipped by 'case' label 原因及解决办法
- initialization of 'XXX' is skipped by 'case' label 原因及解决办法
- initialization of 'XXX' is skipped by 'case' label 原因及解决办法
- initialization of 'XXX' is skipped by 'case' label 原因及解决办法
- initialization of * is skipped by 'default' label
- error C2360: initialization of 'k' is skipped by 'case' label
- initialization of 'strTemp' is skipped by 'case' label解决办法
- error C2361: initialization of 'rect' is skipped by 'default' label
- error C2361: initialization of 'rect' is skipped by 'default' label
- initialization of 'nret' is skipped by 'default' label
- error C2360: initialization of 'j' is skipped by 'case' label
- crosses initialization of “XXX”
- crosses initialization of “XXX”
- 调整心态,走上百万富翁之路
- position
- apache和tomcat整合连接插件下载地址
- u Calculate e解题报告
- switch case 疑点解析
- initialization of xxx is skipped by xxx
- 腾讯笔试挂归
- 15 草率提交任务是不负责任的行为
- ghost手动安装系统后,只剩下一个盘了
- 账龄分析核对的操作步骤,解决客户不会核对账龄与业务明细的问题
- 使用format实现定长左对齐或右对齐
- 新发地,物流港,锦绣大地
- GeekOS源代码学习(1) fd_boot.asm 和 setup.asm
- 使用LCD和USB键盘作为终端