MinGW g++ cannot find std::stof
MinGW g++ cannot find std::stof
我刚刚用gcc 4.8.1(最新版本)从头开始(重新)安装了MinGW,下面的程序不会编译:
#include <iostream>
#include <string>
int main()
{
float f;
std::string s = "5.235";
f = std::stof(s);
std::cout << f << 'n';
}
这是我使用的命令:
g++ -std=c++11 -o test test.cpp
我得到这个错误:
test.cpp:8:9: error: 'stof' is not a member of 'std'
f = std::stof(s);
^
声明std::stof
的文件bitsbasic_string.h
正确地包含在string
头中,我检查了bitsbasic_string.h
中std::stof的声明,它就在那里。
在谷歌上搜索了一下之后,我确实找到了一些MinGW(4.6-4.7)的旧补丁,但它们似乎无关紧要,因为我使用的是gcc 4.8。
有什么想法吗?提前谢谢。
不确定确切的问题,但请检查mingw-w64他们现在有gcc 4.9.2。它能很好地编译您的代码。(但由于sourceforge.net上的mingw-w64项目正在转移到mingw-w64.org,因此最好使用mingw-w64.org)
尽管它的名字,它提供了x86和x64目标的编译器。
也许这应该是一个评论,而不是一个答案
相关文章:
- 使用std::multimap迭代器创建std::list
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- 从持续时间构造std::chrono::system_clock::time_point
- std::具有相同基类的类的变体
- std::向量与传递值的动态数组
- 使用std::vector的OpenCL矩阵乘法
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- std::condition_variable::wait()如何评估给定的谓词
- 如何获取std::result_of函数的返回类型
- std::原子加载和存储都需要吗
- 将对象移动到std::shared_ptr
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 使用一个考虑到std::map中键值的滚动或换行的键
- 当应该使用它们时,std::stof 和 atof 有什么区别?
- 相关功能家族的通用功能(例如std :: stoi,std :: stof,std :: stod等)
- 为什么std::stof、std::stod和std::stold处理异常错误
- MinGW g++ cannot find std::stof