-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Description
With cppwinrt 2.0.201008.2, the following does not compile with Visual Studio 2019 16.8 Preview 3.2 with /std:c++latest:
#include <coroutine>
#include <winrt/base.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Devices.Bluetooth.h>
using namespace winrt;
using winrt::Windows::Foundation::IAsyncOperation;
IAsyncOperation<Windows::Devices::Bluetooth::BluetoothLEDevice> foo()
{
auto bluetoothAdapter = co_await Windows::Devices::Bluetooth::BluetoothAdapter::GetDefaultAsync();
co_return nullptr;
}with the error:
...Generated Files\winrt\base.h(8415,46): error C2338: Not an awaitable type
...Generated Files\winrt\base.h(8460,30): error C2039: 'await_resume': is not a member of 'winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Devices::Bluetooth::BluetoothAdapter>'
If the build is reverted to legacy coroutines by passing /await and including <experimental/coroutine> instead, the code compiles successfully.
The problem appears to be that the various co_await operators in Windows.Foundation.h have the following conditional:
#if defined(__cpp_coroutines)which is the feature-test macro for the legacy Coroutines TS, rather than also including __cpp_lib_coroutine. Furthermore, the adapters themselves may need some adjustments, although I have not looked into that.
There appear to be a few other places that still only test for the Coroutines TS macro.
Metadata
Metadata
Assignees
Labels
No labels