From 8c79530e076838497e514ae256d9aee15a226579 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 24 Feb 2023 09:10:46 -0800 Subject: Update the predicate for `ABSL_INTERNAL_HAS_RTTI` for Windows builds. Abseil defines `ABSL_INTERNAL_HAS_RTTI` by: ``` !defined(__GNUC__) || defined(__GXX_RTTI) ``` This predicate correctly decides rtti for GNU platforms. This predicate is always true for non-GNU platforms. It is not true that rtti is always enabled for non-GNU platforms. For example, when building with `cl.exe` and disabling rtti with `\GR-`, this clause is true. This leads to errors in Windows builds that disable rtti. This default behavior is not decidably correct, but the default behavior shouldn't change. It is better to guess that rtti is on, because if rtti is actually off, compilation will fail, and no programs will be harmed. This change updates the non-default behavior to include a check for rtti on Windows platforms. This change preserves the default behavior. PiperOrigin-RevId: 512085922 Change-Id: I1add0b9b8ca2de5d1313c8aed5ba2019632ab68a --- absl/base/config.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'absl/base') diff --git a/absl/base/config.h b/absl/base/config.h index a17547be..e8605ab3 100644 --- a/absl/base/config.h +++ b/absl/base/config.h @@ -878,7 +878,9 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || // RTTI support. #ifdef ABSL_INTERNAL_HAS_RTTI #error ABSL_INTERNAL_HAS_RTTI cannot be directly set -#elif !defined(__GNUC__) || defined(__GXX_RTTI) +#elif (defined(__GNUC__) && defined(__GXX_RTTI)) || \ + (defined(_MSC_VER) && defined(_CPPRTTI)) || \ + (!defined(__GNUC__) && !defined(_MSC_VER)) #define ABSL_INTERNAL_HAS_RTTI 1 #endif // !defined(__GNUC__) || defined(__GXX_RTTI) -- cgit v1.2.3