C++/WinRT coroutine include confusion

436 views Asked by At

I am trying to follow this getting started page for C++/WinRT, and I am using the Universal C Runtime clang recommended for MSYS2 here. I am using Windows SDK 10.0.22621.0 (the most current available for windows 10 at the moment). I am experiencing an include error for the coroutine header file and am seeking clarification. In the "Windows Kits/10/Include/10.0.22621.0/cppwinrt/winrt/base.h" file, which is a dependency of windows.foundation.collections.h, there is this confusing include block:

#ifdef __cpp_lib_coroutine // not defined at this point because not included yet

#include <coroutine> // so this include doesn't happen...?
// This is my question, under what condition is this #ifdef block supposed to trigger?
// Because it should and it isn't.

namespace winrt::impl
{
    template <typename T = void>
    using coroutine_handle = std::coroutine_handle<T>;

    using suspend_always = std::suspend_always;
    using suspend_never = std::suspend_never;
}

#else


// and instead this include happens, which is incorrect because coroutine is not
// experimental as of early 2019 (https://en.cppreference.com/w/cpp/utility/feature_test)
// https://en.cppreference.com/w/cpp/header/coroutine
#include <experimental/coroutine>

namespace winrt::impl
{
    template <typename T = void>
    using coroutine_handle = std::experimental::coroutine_handle<T>;

    using suspend_always = std::experimental::suspend_always;
    using suspend_never = std::experimental::suspend_never;
}

#endif

I apologize if this is a noob question with a simple answer, but I have been struggling with this for hours, thanks for any insight.

0

There are 0 answers