如何编译#include< experimental/any>用于OSX上的clang [英] How to compile #include <experimental/any> for clang on OSX
问题描述
我正在尝试让#include <experimental/any>
在我的C ++程序中使用clang OSX
I am trying to get the #include <experimental/any>
to compile in my C++ program on clang OSX
// test.cpp
#include <experimental/any>
int main() {
return 0;
}
尝试从此处中了解到的以下命令/选项
Tried following commands/options as learnt from here
clang++ -std=c++14 test.cpp -o test -std=c++1z -stdlib=libc++
clang++ -std=c++1x test.cpp -o test -std=c++1z -stdlib=libc++
clang++ -std=c++1y test.cpp -o test -std=c++1z -stdlib=libc++
clang++ -std=c++1z test.cpp -o test -std=c++1z -stdlib=libc++
但是它不能编译&抱怨以下错误:
fatal error: 'experimental/any' file not found
clang++ --version
产生以下内容:
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
如何获取#include <experimental/any>
进行编译?
How can I get #include <experimental/any>
to compile?
我应该在机器上升级clang吗?
截至目前,clang当前是否支持C ++ 17?如果是,如何获得支持?
推荐答案
对于OSX 10.12.5(使用Xcode Developer工具),我们得到
For OSX 10.12.5 (using Xcode Developer tools), we get
> clang++ -v
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
/Library/Developer/CommandLineTools/usr/include/c++/v1/experimental
中没有any
,只有
chrono
optional
string_view
tuple
utility
algorithm
dynarray
ratio
system_error
type_traits
因此,似乎Apple的libc ++不提供any
(在/Library/Developer/CommandLineTools/usr/include/c++/v1/
中也没有any
).您必须使用GCC或您自己的clang或 boost/any.hpp
,您可以通过自制软件进行安装.
So, it appears that Apple's libc++ does not provide any
(there is no any
in /Library/Developer/CommandLineTools/usr/include/c++/v1/
either). You must either use GCC or your own clang or boost/any.hpp
, all of which you can install via homebrew.
这篇关于如何编译#include< experimental/any>用于OSX上的clang的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!