From 9ff06c16649468aec34b71422bc0677e7f3691b0 Mon Sep 17 00:00:00 2001 From: Paul Bowen-Huggett Date: Sat, 8 Jun 2024 14:33:50 +0200 Subject: [PATCH] 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.) --- docs/CONTRIBUTORS | 1 + include/verilated_timing.h | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 90fa0a745..1f5c199cb 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -146,6 +146,7 @@ Nathan Myers Nolan Poe Oleh Maksymenko Patrick Stewart +Paul Bowen-Huggett Paul Swirhun Paul Wright Pawel Jewstafjew diff --git a/include/verilated_timing.h b/include/verilated_timing.h index 10112dcb3..35b7d1ea7 100644 --- a/include/verilated_timing.h +++ b/include/verilated_timing.h @@ -32,14 +32,18 @@ // clang-format off // Some preprocessor magic to support both Clang and GCC coroutines with both libc++ and libstdc++ #if defined _LIBCPP_VERSION // libc++ -# if __clang_major__ > 13 // Clang > 13 warns that coroutine types in std::experimental are deprecated -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-experimental-coroutine" +# if defined(__has_include) && !__has_include() && __has_include() +# if __clang_major__ > 13 // Clang > 13 warns that coroutine types in std::experimental are deprecated +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-experimental-coroutine" +# endif +# include + namespace std { + using namespace experimental; // Bring std::experimental into the std namespace + } +# else +# include # endif -# include - namespace std { - using namespace experimental; // Bring std::experimental into the std namespace - } #else # 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++