Commit 8c79530e by Abseil Team Committed by Copybara-Service

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
parent 4825ef40
...@@ -878,7 +878,9 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || ...@@ -878,7 +878,9 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
// RTTI support. // RTTI support.
#ifdef ABSL_INTERNAL_HAS_RTTI #ifdef ABSL_INTERNAL_HAS_RTTI
#error ABSL_INTERNAL_HAS_RTTI cannot be directly set #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 #define ABSL_INTERNAL_HAS_RTTI 1
#endif // !defined(__GNUC__) || defined(__GXX_RTTI) #endif // !defined(__GNUC__) || defined(__GXX_RTTI)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment