Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement upcoming STL C++20 coroutines support #676

Closed
sylveon opened this issue Jul 3, 2020 · 13 comments · Fixed by #748
Closed

Implement upcoming STL C++20 coroutines support #676

sylveon opened this issue Jul 3, 2020 · 13 comments · Fixed by #748

Comments

@sylveon
Copy link
Contributor

sylveon commented Jul 3, 2020

The Microsoft STL has recently merged non-experimental coroutine support: microsoft/STL#894

This support, once shipped (expected around 16.8 preview 1), will prevent mixing code using the new coroutines and the experimental ones.

Using the /await command line (which is forced in various places by the C++/WinRT project files) will prevent including <coroutine>, telling you to use <experimental/coroutine>. Similarly, using the /std:c++latest command line (my code makes use of many new C++ 20 only features), will prevent including <experimental/coroutine>, telling you to instead use <coroutine>.

This puts me in a weird spot: I can't include <coroutine> because C++/WinRT uses <experimental/coroutine> and /await, but neither can I include <experimental/coroutine> because I use /std:c++latest.

Ideally, the C++/WinRT headers should detect the presence of C++20 coroutines (using __cpp_impl_coroutine) and use the right header. Additionally, the project files should not force /await in VS 16.8 and newer, or provide a way to opt-out from this behavior.

@kennykerr
Copy link
Collaborator

Yes, it might soon be time to create a C++17 branch for servicing and then switch master over to C++20. I'd like to avoid supporting both C++17 and C++20 as it can become quite complex especially since Clang and Visual C++ are never quite in line.

@DefaultRyan
Copy link
Member

It looks like you're saying VC++ in C++17 mode does not define __cpp_impl_coroutine. Did I read that correctly?

@sylveon
Copy link
Contributor Author

sylveon commented Jul 17, 2020

@sylveon
Copy link
Contributor Author

sylveon commented Aug 8, 2020

It happened, VS 16.8 Preview 1 is out and my code doesn't compile anymore:

image

@sylveon
Copy link
Contributor Author

sylveon commented Aug 8, 2020

Looks like __cpp_impl_coroutine isn't defined yet so existing code using <experimental/coroutine> will build fine (once this is defined <experimental/coroutine> will stop working with /std:c++latest), but trying to use <coroutine> anywhere else will fail because of the C++/WinRT props file forcing /await

@AlexBAV
Copy link

AlexBAV commented Sep 15, 2020

Now VS 16.8 Preview 3.0 is out with "full C++20 coroutines support".
What is the ETA of WinRT support for conformant coroutines?
What is the recommended (if any) way to switch own code to C++20 coroutines and still use the current version of WinRT?

@kennykerr
Copy link
Collaborator

I've been away for a few weeks but should be back in the "office" next week and plan to take a look at 16.8 support.

@DethRaid
Copy link

Subscribed to this issue because I'm also blocked by it

@kennykerr
Copy link
Collaborator

The C++/WinRT library has been updated to support both C++17 and C++20 coroutines.

@DethRaid
Copy link

Can confirm that I'm now un-blocked. Thank you so much!

@mauriceackel
Copy link

Hi @kennykerr,

I was just trying to build my C++/WinRT header (which I have created using cppwinrt.exe -input local -output .) with c++20. However, there seems to be an obvious error with this. My base.h header includes the passage:

#ifndef __clang__

#include <experimental/coroutine>

#else
...

Which will try to include <experimental/coroutine> as I compile with MSVC.

My cppwinrt.exe version is C++/WinRT v2.0.200203.5. I'm a bit confused at the moment given that some people reportedly were able to successfully compile with c++20... Do you perhaps see where the issue is?

@sylveon
Copy link
Contributor Author

sylveon commented Oct 9, 2021

That cppwinrt version is super old, it seems to be from around February 2020. Try the NuGet for an up to date version.

@mauriceackel
Copy link

Oh well.. Shame on me 😓 I just installed it yesterday via a Nuget package but somehow I have managed to install an old version.. Tried it with the news version of cppwinrt.exe and what do you know, no compile errors anymore 🚀

Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants