Fix 'experimental/coroutine' file not found on macOS (#5030) (#5031) (#5151)

libcxx has removed the experimental/coroutine include file in favor of
the C++20-standard coroutine include. If the latter is available we
use it otherwise falling back to the existing experimental version (in
which case we also disable the deprecated-experimental-coroutine warning).

(See also https://reviews.llvm.org/D108697.)
This commit is contained in:
Paul Bowen-Huggett 2024-06-08 14:33:50 +02:00 committed by GitHub
parent 1537c9badc
commit 9ff06c1664
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View File

@ -146,6 +146,7 @@ Nathan Myers
Nolan Poe Nolan Poe
Oleh Maksymenko Oleh Maksymenko
Patrick Stewart Patrick Stewart
Paul Bowen-Huggett
Paul Swirhun Paul Swirhun
Paul Wright Paul Wright
Pawel Jewstafjew Pawel Jewstafjew

View File

@ -32,14 +32,18 @@
// clang-format off // clang-format off
// Some preprocessor magic to support both Clang and GCC coroutines with both libc++ and libstdc++ // Some preprocessor magic to support both Clang and GCC coroutines with both libc++ and libstdc++
#if defined _LIBCPP_VERSION // libc++ #if defined _LIBCPP_VERSION // libc++
# if __clang_major__ > 13 // Clang > 13 warns that coroutine types in std::experimental are deprecated # if defined(__has_include) && !__has_include(<coroutine>) && __has_include(<experimental/coroutine>)
# pragma clang diagnostic push # if __clang_major__ > 13 // Clang > 13 warns that coroutine types in std::experimental are deprecated
# pragma clang diagnostic ignored "-Wdeprecated-experimental-coroutine" # pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-experimental-coroutine"
# endif
# include <experimental/coroutine>
namespace std {
using namespace experimental; // Bring std::experimental into the std namespace
}
# else
# include <coroutine>
# endif # endif
# include <experimental/coroutine>
namespace std {
using namespace experimental; // Bring std::experimental into the std namespace
}
#else #else
# if defined __clang__ && defined __GLIBCXX__ && !defined __cpp_impl_coroutine # if defined __clang__ && defined __GLIBCXX__ && !defined __cpp_impl_coroutine
# define __cpp_impl_coroutine 1 // Clang doesn't define this, but it's needed for libstdc++ # define __cpp_impl_coroutine 1 // Clang doesn't define this, but it's needed for libstdc++