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
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 ++
Hello World:
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);
www.cplusplus.com /.../ strtol
还提到了一个类似的mingw错误此处
A similar mingw bug is mentioned also here
std::stoi不存在于g ++ 4.6.1上MinGW < a>
std::stoi doesn't exist in g++ 4.6.1 on MinGW
这篇关于cygwin g ++ std :: stoi“错误:'stoi'不是'std的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!