尝试在Linux上使用Clang++编译c++11 regex教程时出错
Error while trying to compile c++11 regex tutorial with Clang++ on Linux
我正在努力学习本教程中关于C++11中regex的内容。当我试图编译这个小代码示例时,我得到了这些错误
clang++ -std=c++0x test.cpp -o test
In file included from test.cpp:3:
In file included from /usr/include/c++/4.6/regex:55:
/usr/include/c++/4.6/bits/regex_constants.h:196:36: error: constexpr variable
'match_default' must be initialized by a constant expression
static constexpr match_flag_type match_default = 0;
^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:203:36: error: constexpr variable
'match_not_bol' must be initialized by a constant expression
static constexpr match_flag_type match_not_bol = 1 << _S_not_bol;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:210:36: error: constexpr variable
'match_not_eol' must be initialized by a constant expression
static constexpr match_flag_type match_not_eol = 1 << _S_not_eol;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:216:36: error: constexpr variable
'match_not_bow' must be initialized by a constant expression
static constexpr match_flag_type match_not_bow = 1 << _S_not_bow;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:222:36: error: constexpr variable
'match_not_eow' must be initialized by a constant expression
static constexpr match_flag_type match_not_eow = 1 << _S_not_eow;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:228:36: error: constexpr variable
'match_any' must be initialized by a constant expression
static constexpr match_flag_type match_any = 1 << _S_any;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:233:36: error: constexpr variable
'match_not_null' must be initialized by a constant expression
static constexpr match_flag_type match_not_null = 1 << _S_not_null;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:238:36: error: constexpr variable
'match_continuous' must be initialized by a constant expression
static constexpr match_flag_type match_continuous = 1 << _S_continuous;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:245:36: error: constexpr variable
'match_prev_avail' must be initialized by a constant expression
static constexpr match_flag_type match_prev_avail = 1 << _S_prev_avail;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:273:36: error: constexpr variable
'format_default' must be initialized by a constant expression
static constexpr match_flag_type format_default = 0;
^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:281:36: error: constexpr variable
'format_sed' must be initialized by a constant expression
static constexpr match_flag_type format_sed = 1 << _S_sed;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:288:36: error: constexpr variable
'format_no_copy' must be initialized by a constant expression
static constexpr match_flag_type format_no_copy = 1 << _S_no_copy;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/bits/regex_constants.h:294:36: error: constexpr variable
'format_first_only' must be initialized by a constant expression
static constexpr match_flag_type format_first_only = 1 << _S_first_only;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 errors generated.
怎么了?
clang++ -stdlib=libc++ source.cpp -o source
非常适合我使用教程中的第一个示例代码。
然而,将libc++和libstdc++库/可执行文件链接在一起不是一个好主意——它们是不兼容的。
相关文章:
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- 编译器不会使用 -std=c++11 编译智能指针
- 如何在 C++11 编译时构建具有递增值的整数成员的结构序列
- 无法用"-std=c++11"编译《你好世界》
- 为 freebsd 11 编译 gcc4.8.5 时出错: 错误: 未知类型名称 'choke'
- 如何使用Codelite 11.0.0编译静态库
- mingw:使用 -std=c++11 编译时找不到函数
- 如何在 ubuntu 12.10 中隐藏 g++ c++11 编译警告
- 用C++14编译器而不是C++11编译时,我的性能会提高吗
- Qmake 不使用 stdc++11 编译标志
- 为什么 std::stoi 和 std::array 不能使用 g++ c++11 编译
- Makefile C++11-编译为静态库
- 代码块中的C++11编译问题
- gcc在c++11编译中给出垃圾
- 如何告诉一个库是使用C++11编译的
- 使用makefile和c++11编译时出错
- c++ 11编译时组合两个字符串的最简单方法
- 用Visual Studio 11编译的可执行文件有什么特别之处,导致这些可执行文件不能在Windows XP上执行?
- c++ 11编译时调用printf的格式字符串字面值构造
- 如何在Xcode 8下用c++ 11编译一个项目