cppcoro icon indicating copy to clipboard operation
cppcoro copied to clipboard

Define CPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER for gcc and modern MSVC

Open RedBeard0531 opened this issue 1 year ago • 1 comments

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.

https://github.com/lewissbaker/cppcoro/blob/391215262bd40d68ac6534810164131f5f9eb148/include/cppcoro/config.hpp#L33-L44

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

RedBeard0531 avatar Mar 22 '23 14:03 RedBeard0531

FYI, I ran into this while comparing codegen between gcc and clang on godbolt, where cppcoro is an easy way to quickly play with coroutines. When doing this I couldn't make sense of the gcc codegen until I realized that it was actually being fed different code than clang. When I added -DCPPCORO_COMPILER_SUPPORTS_SYMMETRIC_TRANSFER to the command line, everything made sense again. Hopefully nobody else has to go through this fun discovery process.

RedBeard0531 avatar Mar 22 '23 14:03 RedBeard0531