在< experimental / any>上出现clang ++错误; [英] clang++ error on <experimental/any>

查看:93
本文介绍了在< experimental / any>上出现clang ++错误;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译包含< experimental / any> 的代码时出现错误。

I get an error when compile code containing <experimental/any>.

<$中的代码c $ c> main.cpp :

#include <experimental/any>
int main() { }

编译如下(lang语版本为3.9):

Compile this (clang version is 3.9):

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

编译后出错:

In file included from main.cpp:2:
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/experimental/any:364:34: error: 
      no template named '__any_caster'; did you mean 'any_cast'?
        return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
                                        ^
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/experimental/any:361:30: note: 
      'any_cast' declared here
    inline const _ValueType* any_cast(const any* __any) noexcept
                             ^
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/experimental/any:372:34: error: 
      no template named '__any_caster'; did you mean 'any_cast'?
        return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
                                        ^
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/experimental/any:369:24: note: 
      'any_cast' declared here
    inline _ValueType* any_cast(any* __any) noexcept
                       ^
2 errors generated.


推荐答案

评论中提到的.com / users / 962089 / chris> @ chris


您可以尝试使用libc ++。 libstdc ++的新标头中可能与Clang不兼容。

You could try with libc++. Perhaps there's an incompatibility with Clang in libstdc++'s new header.

事实证明这是事实。 Clang 3.9仍然是实验性的,因此它使用了实验性的头文件,包括实验性的C ++标准库。默认情况下,它是由GCC提供的,因此GCC实现和Clang实现之间会发生不兼容。

This turns out to be true. Clang 3.9 is still experimental, and so it uses experimental headers, including a experimental C++ standard library. By default, it is provided by GCC, and so an incompatibility occurs between the GCC implementation and the Clang implementation.

这篇关于在&lt; experimental / any&gt;上出现clang ++错误;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆