From e0f4b3ec5f36ff90dbea21aab2190fb4565ca67b Mon Sep 17 00:00:00 2001 From: Manoj Gupta Date: Mon, 17 Apr 2023 13:33:15 -0700 Subject: gdb: Fix building with latest libc++ Latest libc++[1] causes transitive include to when or header is included. This causes gdb to not build[2] since defines isupper/islower etc. functions that are explicitly macroed-out in safe-ctype.h to prevent their use. Use the suggestion from libc++ to include internally when building in C++ mode to avoid build errors. Use safe-gdb-ctype.h as the include instead of "safe-ctype.h" to keep this isolated to gdb since rest of binutils does not seem to use much C++. [1]: https://reviews.llvm.org/D144331 [2]: https://issuetracker.google.com/issues/277967395 --- gdbsupport/common-utils.cc | 2 +- gdbsupport/gdb-safe-ctype.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'gdbsupport') diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc index 4a96f2c0e11..a2dde636011 100644 --- a/gdbsupport/common-utils.cc +++ b/gdbsupport/common-utils.cc @@ -20,7 +20,7 @@ #include "common-defs.h" #include "common-utils.h" #include "host-defs.h" -#include "safe-ctype.h" +#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/gdb-xfree.h" void * diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h index f9743ba26f1..bec85c0014d 100644 --- a/gdbsupport/gdb-safe-ctype.h +++ b/gdbsupport/gdb-safe-ctype.h @@ -23,7 +23,9 @@ /* After safe-ctype.h is included, we can no longer use the host's ctype routines. Trying to do so results in compile errors. Code that uses safe-ctype.h that wants to refer to the locale-dependent - ctype functions must call these wrapper versions instead. */ + ctype functions must call these wrapper versions instead. + When compiling in C++ mode, also include before "safe-ctype.h" + which also defines is* functions. */ static inline int gdb_isprint (int ch) @@ -41,6 +43,7 @@ gdb_isprint (int ch) #undef ISUPPER #undef ISXDIGIT +#include #include "safe-ctype.h" #endif -- cgit v1.2.1