to_string不是std的成员,说g ++(mingw) [英] to_string is not a member of std, says g++ (mingw)
问题描述
我正在制作一个小词汇记忆程序,在这个程序中,词语会随机闪现在我的意思之中。我想用Bjarne Stroustroup告诉我们的标准C ++库,但是我遇到了一个看起来很奇怪的问题。
I am making a small vocabulary remembering program where words would would be flashed at me randomly for meanings. I want to use standard C++ library as Bjarne Stroustroup tells us, but I have encountered a seemingly strange problem right out of the gate.
我想将 long
整数更改为 std :: string
以便能够将其存储在文件中。我已经雇用了 to_string()
。问题是,当我用g ++(版本号4.7.0 --version标志中提到的)编译它时,它说:
I want to change a long
integer into std::string
so as to be able to store it in a file. I have employed to_string()
for the same. The problem is, when I compile it with g++ (version 4.7.0 as mentioned in its --version flag), it says:
PS C:\Users\Anurag\SkyDrive\College\Programs> g++ -std=c++0x ttd.cpp
ttd.cpp: In function 'int main()':
ttd.cpp:11:2: error: 'to_string' is not a member of 'std'
出现此错误的程序是:
My program that gives this error is:
#include <string>
int main()
{
std::to_string(0);
return 0;
}
但是,我知道这不可能是因为msdn库清楚地说明了它存在和表示可以使用 -std = c + + 0x
标志。我在做什么错了?
But, I know it can't be because msdn library clearly says it exists and an earlier question on Stack Overflow (for g++ version 4.5) says that it can be turned on with the -std=c++0x
flag. What am I doing wrong?
推荐答案
这是MinGW下的一个已知错误。 相关的Bugzilla 。在评论部分,您可以获得一个补丁,以使其与MinGW协同工作。
This is a known bug under MinGW. Relevant Bugzilla. In the comments section you can get a patch to make it work with MinGW.
这个问题在MinGW-w64发行版中得到了修正,它比 MinGW-w64项目。尽管有这个名字,该项目还提供了32位和64位的工具链。 Nuwen MinGW发行版也解决了这个问题。
This issue has been fixed in MinGW-w64 distros higher than GCC 4.8.0 provided by the MinGW-w64 project. Despite the name, the project provides toolchains for 32-bit along with 64-bit. The Nuwen MinGW distro also solves this issue.
这篇关于to_string不是std的成员,说g ++(mingw)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!