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

Allow silencing the experimental coroutine warning #2132

Closed
wants to merge 1 commit into from
Closed

Allow silencing the experimental coroutine warning #2132

wants to merge 1 commit into from

Conversation

SpriteOvO
Copy link

@SpriteOvO SpriteOvO commented Aug 17, 2021

Add an option macro to allow users to silence the experimental coroutine warning.

Some third-party libraries (such as cppwinrt) are very slow to distribute new versions. The latest version of cppwinrt currently included in the Windows SDK is v2.0.200609.3, which was released on (9 Jun 2020).

In the older version of these libraries (the latest distributed version), it still use the <experimental/coroutine> header. Therefore, if we bump our own projects to C++20, this warning will always prevent compilation.

Using a released but undistributed version sometimes doesn't work, for example cppwinrt, if we use the local version it will require installation through the Nuget package manager, which is almost impossible to do in CMake.

For more information on this problem in cppwinrt, see microsoft/cppwinrt#866.

This PR should not break any existing code, and the <experimental/coroutine> header should work well with the standard <coroutine> header, since they have different namespaces. But I'm not sure the naming of that option macro is appropriate.

@SpriteOvO SpriteOvO requested a review from a team as a code owner August 17, 2021 13:46
@sylveon
Copy link
Contributor

sylveon commented Aug 17, 2021

Why not just use /std:c++20 /await? This enables the legacy pre-C++20 coroutines in C++20 mode.

The 22000 SDK (currently in preview) also has a newer cppwinrt version which correctly handles C++20 coroutines.

@CaseyCarter
Copy link
Member

Sorry, but this is a non-starter. MSVC uses a different ABI for "standard coroutines" than for experimental coroutines. The two cannot coexist in the same translation unit. The only supported configurations are:

  1. Don't specify /await, and #include <coroutine> - works in C++17-or-later modes (yes, we support C++20 coroutines in C++17)
  2. Do specify /await, and #include <experimental/coroutine> - works in all supported language modes. (This may change if C++23 adds library components that use coroutines since they will likely rely on features that "experimental coroutines" cannot support.)

@SpriteOvO
Copy link
Author

SpriteOvO commented Aug 18, 2021

Oh, specifying /await works!
I mistakenly thought that option was only available in C++17. (because of this comment microsoft/cppwinrt#866 (comment))
Thanks a lot guys.

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 this pull request may close these issues.

3 participants