to_string不是std的成员,g ++说 [英] to_string is not a member of std, says g++

查看:1187
本文介绍了to_string不是std的成员,g ++说的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个小词汇记忆程序,其中的话会随机闪现我的意思。我想使用标准的C ++库作为Bjarne Stroustroup告诉我们,但我遇到一个看似奇怪的问题就在门外。

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'

出现此错误的程序是:

#include <string>

int main()
{
    std::to_string(0);
    return 0;
}

但是,我知道它不能是因为msdn库清楚地说它存在,并且在Stack Overflow的早期问题(对于g ++版本4.5)说,它可以使用 -std = c ++ 0x flag。我做错了什么?

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项目提供的高于GCC 4.8.0的MinGW-w64发行版中修复< a>。尽管这个名称,该项目提供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 ++说的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆