amo*_*mos 5 c++ clang libstdc++ c++11 libc++
为什么这不起作用:
#include <regex>
int main() {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译为:
clang++ -std=c++11 -stdlib=libstdc++ temp.cpp
temp.cpp:1:10: fatal error: 'regex' file not found
#include <regex>
^
1 error generated.
clang++ --version
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
Run Code Online (Sandbox Code Playgroud)
如果我能够stdlib成为libc++然后再编译.正则表达式c++11,但clang本身似乎没有问题-std=c++11 -stdlib=libstdc++.至少在我的机器上,它看起来像我可以使用的东西/usr/include/regex.h,但这不是标准的,除了我想使用的正则表达式以外的东西(例如std :: to_string).
这已经想出的原因是因为我想链接到第三方库(对此我没有源),这是符合作为std::string,而不是std::__1::basic_string,但我代码使用std::regex和std::to_string.我不确定是否要引入对boost的依赖.