c++ - 在 VS2015 中使用平台工具设置 "Microsoft CodeGen v140_clang_c2"进行编译时,包括 <functional> 和 <memory> header 会导致错误

标签 c++ clang c++14

<分区>

我已经编译并运行了 this clang 中的代码(也在 gcc6.3 中)并且它们都工作正常。

同样在我的 visual studio 2015 中,我使用以下平台工具集进行了编译。

  • Visual Studio 2013 - Windows XP (v120_xp)
  • Visual Studio 2015 - Windows XP (v140_xp)

两者都编译得很好。

但是当我使用工具集时,

  • Visual Studio 2015 - Clang 与 Microsoft CodeGen (v140_clang_c2)

enter image description here

我得到以下错误

enter image description here

问题似乎是在我包含内存和功能 header 时发生的。

#include <functional>
#include <memory>

知道为什么会这样吗?我该如何避免呢?

最佳答案

正如评论中提到的 1201ProgramAlarm,我必须在属性中启用运行时类型信息。
(对于 visual studio 2015)在属性页中,展开 Configuration Properties->C/C++,然后选择 Language。
No (-fno-rtti) 更改为Yes (-frtti) enter image description here

关于c++ - 在 VS2015 中使用平台工具设置 "Microsoft CodeGen v140_clang_c2"进行编译时,包括 <functional> 和 <memory> header 会导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52470338/

相关文章:

c++ - std::function operator() 和 std::forward 发生了什么?

c++ - 来自多线程 SDL 应用程序的 InvalidCursor 错误

c++ - std::ofstream::open 会把整个文件读入内存吗?

c - 函数指针上的 __attribute__

c++ - 使用 std::experimental::optional 实现列表

c++ - 为 vector 的 vector 提供平坦迭代器的优雅方式

c++ - 关于在 C++ 中使用 "+"的整数变量和字符串连接的非常基本的问题

c++ - 如何通过 cpp 项目文件夹调用 clang-format?

python - 如何使用 clang python 绑定(bind)获取类方法定义?

带有 std::enable_if 的 C++ 可变参数模板部分模板特化