Skip to content

Commit

Permalink
PR #1789: Add missing #ifdef pp directive to the TypeName() function …
Browse files Browse the repository at this point in the history
…in the layout.h

Imported from GitHub PR #1789

If code is being compiled without support for the RTTI, ABSL_INTERNAL_HAS_RTTI pp macro is not defined in the absl/base/config.h (otherwise, if RTTI is supported, it is defined to 1)

Rn this macro is used in the absl/flags/internal/flag.h, absl/flags/internal/flag.cc, absl/types/any.h and absl/container/internal/layout.h. In the first three files it is used like `#ifdef ABSL_INTERNAL_HAS_RTTI`. In the layout.h it is used like `#if ABSL_INTERNAL_HAS_RTTI` which causes trouble if code that uses absl is being compiled with the Wundef warning flag (at least when gcc or clang are used)

Since ABSL_INTERNAL_HAS_RTTI is not defined when RTTI is not used, it seems like it should be used as `#ifdef ABSL_INTERNAL_HAS_RTTI` in the layout.h
Merge 437e7c1 into c7cf999

Merging this change closes #1789

COPYBARA_INTEGRATE_REVIEW=#1789 from i80287:add-missing-ifdef 437e7c1
PiperOrigin-RevId: 702377421
Change-Id: I3241b573d496adba4870c8e4742c3ee759841721
  • Loading branch information
i80287 authored and copybara-github committed Dec 3, 2024
1 parent a3f7e98 commit 742a0ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion absl/container/internal/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ constexpr size_t Max(size_t a, size_t b, Ts... rest) {
template <class T>
std::string TypeName() {
std::string out;
#if ABSL_INTERNAL_HAS_RTTI
#ifdef ABSL_INTERNAL_HAS_RTTI
absl::StrAppend(&out, "<",
absl::debugging_internal::DemangleString(typeid(T).name()),
">");
Expand Down

0 comments on commit 742a0ed

Please sign in to comment.