|
| 1 | +From 5eb20178ba43d7b3fd6dbf97b4d2a0907b59a42a Mon Sep 17 00:00:00 2001 |
| 2 | +From: Severin Strobl <github@severin-strobl.de> |
| 3 | +Date: Wed, 30 Apr 2025 10:34:55 +0200 |
| 4 | +Subject: [PATCH] Use <version> for libc++ detection on C++20 and beyond (#901) |
| 5 | + |
| 6 | +--- |
| 7 | + doctest/doctest.h | 8 ++++++-- |
| 8 | + doctest/parts/doctest_fwd.h | 8 ++++++-- |
| 9 | + 2 files changed, 12 insertions(+), 4 deletions(-) |
| 10 | + |
| 11 | +diff --git a/doctest/doctest.h b/doctest/doctest.h |
| 12 | +index 52b4a4aa3..4a1e4a09d 100644 |
| 13 | +--- a/doctest/doctest.h |
| 14 | ++++ b/doctest/doctest.h |
| 15 | +@@ -490,13 +490,17 @@ DOCTEST_GCC_SUPPRESS_WARNING_POP |
| 16 | + #endif |
| 17 | + #endif // DOCTEST_CONFIG_USE_IOSFWD |
| 18 | + |
| 19 | +-// for clang - always include ciso646 (which drags some std stuff) because |
| 20 | +-// we want to check if we are using libc++ with the _LIBCPP_VERSION macro in |
| 21 | ++// for clang - always include <version> or <ciso646> (which drags some std stuff) |
| 22 | ++// because we want to check if we are using libc++ with the _LIBCPP_VERSION macro in |
| 23 | + // which case we don't want to forward declare stuff from std - for reference: |
| 24 | + // https://github.com/doctest/doctest/issues/126 |
| 25 | + // https://github.com/doctest/doctest/issues/356 |
| 26 | + #if DOCTEST_CLANG |
| 27 | ++#if DOCTEST_CPLUSPLUS >= 201703L && __has_include(<version>) |
| 28 | ++#include <version> |
| 29 | ++#else |
| 30 | + #include <ciso646> |
| 31 | ++#endif |
| 32 | + #endif // clang |
| 33 | + |
| 34 | + #ifdef _LIBCPP_VERSION |
| 35 | +diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h |
| 36 | +index 20ed9d874..9532c1f3a 100644 |
| 37 | +--- a/doctest/parts/doctest_fwd.h |
| 38 | ++++ b/doctest/parts/doctest_fwd.h |
| 39 | +@@ -487,13 +487,17 @@ DOCTEST_GCC_SUPPRESS_WARNING_POP |
| 40 | + #endif |
| 41 | + #endif // DOCTEST_CONFIG_USE_IOSFWD |
| 42 | + |
| 43 | +-// for clang - always include ciso646 (which drags some std stuff) because |
| 44 | +-// we want to check if we are using libc++ with the _LIBCPP_VERSION macro in |
| 45 | ++// for clang - always include <version> or <ciso646> (which drags some std stuff) |
| 46 | ++// because we want to check if we are using libc++ with the _LIBCPP_VERSION macro in |
| 47 | + // which case we don't want to forward declare stuff from std - for reference: |
| 48 | + // https://github.com/doctest/doctest/issues/126 |
| 49 | + // https://github.com/doctest/doctest/issues/356 |
| 50 | + #if DOCTEST_CLANG |
| 51 | ++#if DOCTEST_CPLUSPLUS >= 201703L && __has_include(<version>) |
| 52 | ++#include <version> |
| 53 | ++#else |
| 54 | + #include <ciso646> |
| 55 | ++#endif |
| 56 | + #endif // clang |
| 57 | + |
| 58 | + #ifdef _LIBCPP_VERSION |
0 commit comments