to_string is not a member of std, says g++ (mingw)(g++ (mingw) 说 to_string 不是 std 的成员)
问题描述
我正在制作一个小词汇记忆程序,其中单词会随机闪现给我以获取含义.我想使用 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:UsersAnuragSkyDriveCollegePrograms> 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 库明确说明 它存在并且一个较早的问题关于堆栈溢出(对于 g++ 4.5 版)说它可以使用 -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.在评论部分,您可以获得 patch 以使其与 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 发行版中得到修复项目.尽管名称如此,但该项目提供了 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.
这篇关于g++ (mingw) 说 to_string 不是 std 的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:g++ (mingw) 说 to_string 不是 std 的成员


基础教程推荐
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 设计字符串本地化的最佳方法 2022-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04