summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-02-24 09:10:46 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-02-24 09:11:36 -0800
commit8c79530e076838497e514ae256d9aee15a226579 (patch)
tree3aa88981e91b11832e85ec93e817639d95164895 /absl/base
parent4825ef40953aeb4a71e3625203b760381da6b0d7 (diff)
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
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/config.h4
1 files changed, 3 insertions, 1 deletions
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)