G++ 'stod'未在此范围内声明
g++ 'stod' was not declared in this scope
我正试图在cygwin中使用g++(版本4.8.1)编译以下代码,但它似乎无法使用函数stod():
//test.cpp
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
string a="1.23";
cout<<stod(a);
return 0;
}
我一直得到这个eroor:
test.cpp:9:14: error: 'stod' was not declared in this scope
cout<<stod(a);
我读到另一个有同样问题的线程。在那里,人们建议使用c++11来解决它。所以我尝试了以下两个命令来编译它,但仍然得到了相同的错误:
g++ -std=c++0x test.cpp -o test
g++ -std=c++11 test.cpp -o test
有人知道这个问题的解决办法吗?
我怎么知道c++11已启用?我需要修改我的代码才能使用它吗?
非常感谢!
它在Coliru上的GCC 4.8中工作(http://coliru.stacked-crooked.com/a/8a68ad0ca64c1bff)还有Clang在我的机器上。可能是你的Cygwin系统不支持这个功能。我建议您只需使用好的旧strtod()
即可解决此问题。无论如何,这可能就是stod()
在引擎盖下使用的。
相关文章:
- 错误:未在此范围内声明'reverse'
- 错误:"imread"未在此范围内声明
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- "Main"已在当前范围内声明
- c++ 变量在宏的扩展中没有在这个范围内声明
- C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
- 'num1'未在此范围内声明
- 如何找到在本地范围内声明的变量的地址?
- NT状态未在此范围内声明
- 变量未在此范围内声明 数组线性搜索
- 包含文件中的 Typdef "未在此范围内声明"
- 'ClassName'和'ClassInstance'未在此范围内声明
- C++ 中的类之间的数据重新循环 - 错误:'<class name>'未在此范围内声明
- 代码作为 C 文件工作,但不作为C++文件,错误:'__builtin_types_compatible_p'未在此范围内声明
- 如何修复错误:"vreinterpretq_u32_f64"未在此范围内声明 - 在Android上使用Eigen构建
- 如何修复C++中的"arrStud未在此范围内声明"错误
- 错误:"SHGetKnownFolderPath"未在此范围内声明
- 错误:'Sprite'未在此范围内声明