Skip to content

Define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER for gcc and modern MSVC #216

@RedBeard0531

Description

@RedBeard0531

MSVC now supports symmetric transfer, and I think gcc has since it introduced coroutines support. However, cppcoro currently only uses symmetric transfer for clang >= 7.

/// \def CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER
/// Defined to 1 if the compiler supports returning a coroutine_handle from
/// the await_suspend() method as a way of transferring execution
/// to another coroutine with a guaranteed tail-call.
#if CPPCORO_COMPILER_CLANG
# if __clang_major__ >= 7
# define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER 1
# endif
#endif
#ifndef CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER
# define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER 0
#endif

Rather than hard-coding a bunch more compiler versions, it may make more sense to check for __cpp_impl_coroutine >= 201902 to automatically use symmetric transfer for any compiler that claims compliant support of the final coroutine spec (probably with || __clang_minor__ >= 7 to keep working with old clang).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions