【问题标题】:C++ resumable functions (yield) in visual studio 2015 RC access violationVisual Studio 2015 RC 访问冲突中的 C++ 可恢复函数 (yield)
【发布时间】:2015-07-11 15:37:45
【问题描述】:

我正在尝试来自 MSDN link 的 Visual Studio 2015 RC 中可恢复函数的代码示例。

#include<iostream>
#include<experimental/generator>

auto hello()
{
   for (auto ch : "Hello, world\n")
      yield ch;
}

int main()
{
   for (auto ch : hello())
      std::cout << ch;
}

到目前为止,无论我的编译器设置是什么,代码在运行时都会导致访问冲突异常。

这是我的编译器标志:

/Yu"stdafx.h" /GS- /W3 /Zc:wchar_t /ZI /Gm /Od /sdl- /Fd"x64\Debug\vc140.pdb" /Zc:inline /fp:precise /D" WIN32" /D "_D​​EBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /MDd /Fa"x64\Debug\" /EHsc /nologo / Fo"x64\Debug\" /Fp"x64\Debug\Test.pch"

有人知道如何让它工作吗?

【问题讨论】:

  • 那个链接说的是requires an opt-in switch (/await) to use it.这个特性你有没有试过把它添加到编译器标志中?
  • 是的,我已经有了/await 开关。它只是在对话框的不同部分,所以它没有与其他开关一起复制。

标签: c++ yield visual-studio-2015


【解决方案1】:

我收到了对原始 MSDN link 的评论的回复。问题在于尚不支持的/ZI 标志(用于编辑和继续的程序数据库)。切换到/Zi 有效。

【讨论】:

    猜你喜欢
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 2013-01-14
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多