如何为 OSX 上的 clang 编译 #include <experimental/any>
How to compile #include <experimental/any> for clang on OSX
我正在尝试让 #include <experimental/any>
在我的 C++ 程序中通过 clang OSX
进行编译
// test.cpp
#include <experimental/any>
int main() {
return 0;
}
尝试按照 commands/options 学习
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>
编译?
我应该在我的机器上升级 clang 吗?
截至目前,clang 是否支持 C++17?如果是,如何获得支持?
你拼错了。是 "experimental",不是 "experimentals"。
但是,从 Clang 4.0 开始,您应该只使用 <any>
。
对于 OSX 10.12.5(使用 Xcode 开发者工具),我们得到
> 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
所以,苹果的libc++好像没有提供any
(/Library/Developer/CommandLineTools/usr/include/c++/v1/
里面也没有any
)。您必须使用 GCC 或您自己的 clang 或 boost/any.hpp
, all of which you can install via homebrew.
我正在尝试让 #include <experimental/any>
在我的 C++ 程序中通过 clang OSX
// test.cpp
#include <experimental/any>
int main() {
return 0;
}
尝试按照 commands/options 学习
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>
编译?
我应该在我的机器上升级 clang 吗?
截至目前,clang 是否支持 C++17?如果是,如何获得支持?
你拼错了。是 "experimental",不是 "experimentals"。
但是,从 Clang 4.0 开始,您应该只使用 <any>
。
对于 OSX 10.12.5(使用 Xcode 开发者工具),我们得到
> 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
所以,苹果的libc++好像没有提供any
(/Library/Developer/CommandLineTools/usr/include/c++/v1/
里面也没有any
)。您必须使用 GCC 或您自己的 clang 或 boost/any.hpp
, all of which you can install via homebrew.