c++/winrt coroutine包括混乱

发布于 2025-02-14 00:43:22 字数 1635 浏览 2 评论 0 原文

我正在尝试关注此对于C ++/Winrt,我正在使用Universal C Runtime Clang推荐用于MSYS2 在这里。我正在使用Windows SDK 10.0.22621.0(目前最新的Windows 10最新目前可用于Windows 10)。 我正在遇到包括Coroutine头文件的错误,并正在寻求澄清。在“ Windows套件/10/include/inclate/incepty/cyper/cppwinrt/winrt/base.h”文件

#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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文