其他分享
首页 > 其他分享> > clang 4使用c 1z构建错误

clang 4使用c 1z构建错误

作者:互联网

我刚刚将我的arch linux系统更新到包含gcc 7.1.1的最新版本.试图建立这个:

#include <functional>

int main(int argc, char** argv) {
    return 1;
}

使用命令

clang++ main.cpp -std=c++1z

导致错误:

In file included from main.cpp:1:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/functional:60:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/unordered_map:47:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/hashtable.h:37:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/node_handle.h:39:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:27: error: use of class template 'optional'
      requires template arguments
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                          ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:451:11: note: template is declared here
    class optional
          ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:40: error: expected ';' at end of declaration
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                                       ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:41: error: cannot use arrow operator on a type
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;

这对我来说是个错误吗,是linux,还是clang?

更新:(忘了添加版本)

> gcc包版本7.1.1-2(提供/usr/include / c目录)
> clang包版本4.0.0-3

解决方法:

不太晚,但我想总结一下.

这个:

template <typename _Tp> optional(_Tp) -> optional<_Tp>;

是扣除指南的例子. Here你可以找到这个语言功能的很好的解释.

当-std = c 17或c 1z标志正在使用时,新版本的libstdc在其实现中使用它.
不幸的是,Clang还不支持此功能. Clang C++1z status page仅在SVN上报告.

您可以找到Arch Linux here的错误报告.

标签:archlinux,c,c17,clang-2
来源: https://codeday.me/bug/20191006/1862272.html