cygwin g++ std::stoi "错误:‘stoi’不是‘std’的成员 [英] cygwin g++ std::stoi "error: ‘stoi’ is not a member of ‘std
问题描述
我有:
-cygwin 1.7.25 on windows 7/32bit
-cygwin 1.7.25 on windows 7/32bit
-g++ --version --> g++ (GCC) 4.8.2
-g++ --version --> g++ (GCC) 4.8.2
-libstdc++.a --> gcc-g++-4.8.2-1
-libstdc++.a --> gcc-g++-4.8.2-1
试图制作一个c++你好世界:
Tried to make a c++ Hello World:
#include <string>
int main()
{
std::string s = "123";
int i = std::stoi(s);
}
编译给出:
$ g++ -std=c++11 main.cpp
main.cpp: In function ‘int main()’:
main.cpp:6:10: error: ‘stoi’ is not a member of ‘std’
int i = std::stoi(s);
我搜索了几个小时,但仍然找不到解决方案.这里有什么问题?
I searched for hours but I still could not find a solution. What's the issue here?
推荐答案
这是一个错误,可能是某些库代码到 cygwin 的不完整端口(它是 cplusplus11 的一个特性)——毕竟有些东西必须更改.请务必举报.
That's a bug, possibly an incomplete port of some library code to cygwin (it's a cplusplus11 feature) - some stuff has to be changed after all. Make sure to report it.
解决方案当然很简单:#include <cstdlib>strtol(s.c_str(),0,10);
std::stoi 不存在于MinGW 上的 g++ 4.6.1
这篇关于cygwin g++ std::stoi "错误:‘stoi’不是‘std’的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!