[英]Error: no member named 'stod' in namespace 'std'
我正在Sublime Text 2中运行代码。它显示了一个错误:
item->open = std::stod(temp);
错误是:
error: no member named 'stod' in namespace 'std'
item->open = std::stod(temp);
意识到sublime text 2无法运行c ++ 11代码,所以看到了这篇文章: http : //www.thefourtheye.in/2013/07/Compiling-Cpp-11-Programs-with-Sublime-Text-3。 html
将此代码发布到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}'"]
}
]
}
但是错误仍然存在。 不知道为什么。 需要一些指导...
更新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:更改为c ++ 11。 没变。
{
"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}'"]
}
]
}
看起来您计算机上的Clang版本(伪装为g++
,在Mac上是常见设置)默认情况下仍在使用libstdc ++(GCC的C ++标准库)。 OS X随附的libstdc++
版本很libstdc++
,并且不支持C ++ 11( std::stod
是C ++ 11的新增功能)。
将-stdlib=libc++
传递给编译器,以使其改用Clang的标准库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.