error: jump to label ‘xxxxx’ [-fpermissive]
来源:互联网 发布:php 使用openoffice 编辑:程序博客网 时间:2024/06/03 17:59
C++中使用goto语句可以跳到指定的函数末端,在使用g++编译时,要注意在goto语句出现之后是不允许出现新申明的变量,所以需要申明变量需要放在所有goto语句之前。(VisutalStudio编译无此问题)。
#include <iostream>
void Test(int m)
{
int i = m;
if (i > 10) goto res;
int j = i;
res:
std::cout<<"m > 10"<<std::endl;
}
int _tmain()
{
Test(4);
return 0;
}
此时使用g++编译报错:
root@ubuntu:/home/Temp# g++ -c temp.cpp
temp.cpp: In function ‘void Test(int)’:
temp.cpp:12:1: error: jump to label ‘res’ [-fpermissive]
res:
^
temp.cpp:7:19: error: from here [-fpermissive]
if (i > 10) goto res;
^
temp.cpp:10:6: error: crosses initialization of ‘int j’
int j = i;
将Test方法中代码做如下修改即可:
{
int i = m;
int j;
j = i;
res:
std::cout<<"m > 10"<<std::endl;
}
阅读全文
0 0
- error: jump to label ‘xxxxx’ [-fpermissive]
- error:jump to case label [-fpermissive]
- error: jump to case label [-fpermissive]
- error:jump to case label [-fpermissive]
- error: jump to label ‘XXXX’ [-fpermissive]
- 编译错误 jump to case label [-fpermissive]
- switch 语句:error : crosses initialization of 'xxx' and jump to case label [-fpermissive]
- qt编程中遇到的bug之error: jump to case label [-fpermissive]
- Android之jni编译出现error: jump to label ‘XXXX’ [-fpermissive]解决办法
- error: jump to case label
- error: jump to case label
- error: jump to case label
- error: jump to case label
- error:jump to case label
- C++ goto 在g++ 编译时出现 crosses initialization 和 jump to label xxx [-fpermissive] 错误
- 【C/C++】error: jump to case label
- symbian “error: jump to case label”
- 【C/C++】error: jump to case label
- Huffman编码树
- Spark性能优化指南——基础篇
- 阿牛的EOF牛肉串
- 两个栈实现一个队列和两个队列实现一个栈
- httpclient的使用
- error: jump to label ‘xxxxx’ [-fpermissive]
- Google算法题:吹气球/合石子(区间动态规划)
- 【selenium安装】selenium安装教程
- java将unicode码转换为中文
- springboot【24】监控管理之Actuator的/info端点输出Git版本信息
- 机器学习(周志华)读书笔记-(五)神经网络(2)卷积神经网络
- Python中的CSV读写
- 数据结构--排序系列(插入排序,希尔排序,堆排序)Java代码实现
- 在STL中基本容器string、vector、list、deque、set、map之间的区别