美文网首页技术日常
c++4~gcc4.8.2报错goto语句报错

c++4~gcc4.8.2报错goto语句报错

作者: 摹喵居士 | 来源:发表于2017-08-03 16:42 被阅读36次

2017.08.03

linux下gcc3.4.5下编译通过好的含goto语句c程序,goto跳转到end

使用gcc4.8.2 遇上一下错误提示

error: jump to label ‘end’
error: from here
error: crosses initialization of ‘int x’
error: crosses initialization of ‘int y’

gcc4.8.2在跳转之后还有变量声明的话,它认为后面定义的变量在跳转label定义时尚未初始化,故而编不过去

把所有的变量声明放到第一个goto跳转之前就行。

相关文章

网友评论

    本文标题:c++4~gcc4.8.2报错goto语句报错

    本文链接:https://www.haomeiwen.com/subject/glbplxtx.html