3
votes

I'm trying the code example for resumable functions in Visual Studio 2015 RC from this MSDN link.

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

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

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

So far, no matter what my compiler settings are, the code causes an access violation exception when run.

Here are my compiler flags:

/Yu"stdafx.h" /GS- /W3 /Zc:wchar_t /ZI /Gm /Od /sdl- /Fd"x64\Debug\vc140.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /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"

Anyone figure out how to get it working?

1
That link says the feature requires an opt-in switch (/await) to use it. Have you tried adding that to the compiler flags?Open Kastle
Yes, I already had the /await switch. It was just in a different part of the dialog box, so it didn't copy with the other switches.aligature

1 Answers

3
votes

I got a response from a comment on the original MSDN link. The problem is with the /ZI flag (program database for edit and continue) which is not supported yet. Switching to /Zi works.