【发布时间】:2015-06-17 20:08:06
【问题描述】:
我的操作系统是 ubuntu 14.04,笔记本电脑,i7。
g++ 版本为g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2。
我尝试运行一个简单的代码来测试stoi:
#include <string>
int main()
{
std::string s = "123";
int i = std::stoi(s);
}
当我用:g++ -g prueba2.cpp 编译它时,我得到:
prueba2.cpp: In function ‘int main()’:
prueba2.cpp:6:12: error: ‘stoi’ is not a member of ‘std’
int i = std::stoi(s);
^
当我首先使用g++ -std=c++0x -g prueba2.cpp(我也尝试使用-std=c++11)和dbg 对其进行两次调试时,我得到了:
然后,我也做了一个简单的搜索,并按照here1、here2 和here3 中的建议进行了操作,但都没有成功。
我在做傻事吗?
【问题讨论】:
-
如果编译器给你一个致命错误,是什么让你认为它输出了可运行的代码?
-
那么,问题出在哪里?它是否编译?
-
我该如何解决?我需要更多线索
-
如果你使用
g++ -std=c++11 -g prueba2.cpp,它编译了吗?如果不是,那是什么错误? -
您的代码编译良好,您收到了
exited normally消息。那么,有什么问题呢?
标签: c++ c++11 segmentation-fault coredump