Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 49f647f

Browse files
Fix RTTI check in EncodableValue (#20398)
__has_feature(cxx_rtti) is a clang extension, but clients of this code are mostly using the VS toolchain. This makes the RTTI check work with more compilers.
1 parent 282bfc5 commit 49f647f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

shell/platform/common/cpp/client_wrapper/include/flutter/encodable_value.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@
1414
#include <variant>
1515
#include <vector>
1616

17+
// Unless overridden, attempt to detect the RTTI state from the compiler.
18+
#ifndef FLUTTER_ENABLE_RTTI
19+
#if defined(_MSC_VER)
20+
#ifdef _CPPRTTI
21+
#define FLUTTER_ENABLE_RTTI 1
22+
#endif
23+
#elif defined(__clang__)
24+
#if __has_feature(cxx_rtti)
25+
#define FLUTTER_ENABLE_RTTI 1
26+
#endif
27+
#elif defined(__GNUC__)
28+
#ifdef __GXX_RTTI
29+
#define FLUTTER_ENABLE_RTTI 1
30+
#endif
31+
#endif
32+
#endif // #ifndef FLUTTER_ENABLE_RTTI
33+
1734
namespace flutter {
1835

1936
static_assert(sizeof(double) == 8, "EncodableValue requires a 64-bit double");
@@ -56,7 +73,7 @@ class CustomEncodableValue {
5673
operator std::any &() { return value_; }
5774
operator const std::any &() const { return value_; }
5875

59-
#if __has_feature(cxx_rtti)
76+
#if defined(FLUTTER_ENABLE_RTTI) && FLUTTER_ENABLE_RTTI
6077
// Passthrough to std::any's type().
6178
const std::type_info& type() const noexcept { return value_.type(); }
6279
#endif

0 commit comments

Comments
 (0)