[英]Error: no member named 'stod' in namespace 'std'
I am running a code in Sublime Text 2. It shows me an error: 我正在Sublime Text 2中运行代码。它显示了一个错误:
item->open = std::stod(temp);
The error is: 错误是:
error: no member named 'stod' in namespace 'std'
item->open = std::stod(temp);
Realised that sublime text 2 can't run c++11 code, so saw this post: http://www.thefourtheye.in/2013/07/Compiling-Cpp-11-Programs-with-Sublime-Text-3.html 意识到sublime text 2无法运行c ++ 11代码,所以看到了这篇文章: http : //www.thefourtheye.in/2013/07/Compiling-Cpp-11-Programs-with-Sublime-Text-3。 html
Posted this code in C++.sublime.build: 将此代码发布到C ++。sublime.build中:
{
"cmd": ["g++", "-std=c++0x", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd":["bash", "-c", "g++ -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
But the error still exist. 但是错误仍然存在。 Not sure why.
不知道为什么。 Need some guidance...
需要一些指导...
Update1: 更新1:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
Update2: Changed to c++11. Update2:更改为c ++ 11。 No change.
没变。
{
"cmd": ["g++", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd":["bash", "-c", "g++ -std=c++11 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
Looks like the version of Clang (masquerading as g++
, a common setup on Mac) on your computer is still using libstdc++ (GCC's C++ standard library) by default. 看起来您计算机上的Clang版本(伪装为
g++
,在Mac上是常见设置)默认情况下仍在使用libstdc ++(GCC的C ++标准库)。 The version of libstdc++
that comes with OS X is ancient, and doesn't have C++11 support (and std::stod
is a C++11 addition). OS X随附的
libstdc++
版本很libstdc++
,并且不支持C ++ 11( std::stod
是C ++ 11的新增功能)。
Pass -stdlib=libc++
to your compiler to make it use Clang's standard library instead. 将
-stdlib=libc++
传递给编译器,以使其改用Clang的标准库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.