【发布时间】:2016-04-16 05:23:45
【问题描述】:
为什么这不起作用:
#include <regex>
int main() {
return 0;
}
编译为:
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
如果我允许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 的依赖。
【问题讨论】:
标签: c++ c++11 clang libstdc++ libc++