I have:
-Windows 7/32 位上的 cygwin 1.7.25
-g++ --版本 --> g++ (GCC) 4.8.2
-libstdc++.a --> gcc-g++-4.8.2-1
试图制作一个c++
你好世界:
#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);
我搜索了几个小时但仍然找不到解决方案。这里有什么问题?
这是一个错误,可能是某些库代码到 cygwin 的不完整移植(它是 cplusplus11 功能)——毕竟有些东西必须更改。请务必报告。
解决方案当然很简单:#include <cstdlib> strtol(s.c_str(),0,10);
www.cplusplus.com/.../strtol http://www.cplusplus.com/reference/cstdlib/strtol/
还提到了类似的 mingw bughere http://tehsausage.com/mingw-to-string
MinGW 上的 g++ 4.6.1 中不存在 std::stoi https://stackoverflow.com/questions/8542221/stdstoi-doesnt-exist-in-g-4-6-1-on-mingw
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)