public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] safe-ctype.h: Fix building with latest libc++
@ 2023-04-13 19:44 Manoj Gupta
  2023-04-14 13:29 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Manoj Gupta @ 2023-04-13 19:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: manojgupta

Latest libc++[1] causes transitive include to <locale> when
<mutex> or <thread> header is included. This causes
gdb to not build[2] since <locale> 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 <locale> internally when
building in C++ mode to avoid build errors.

[1]: https://reviews.llvm.org/D144331
[2]: https://issuetracker.google.com/issues/277967395
---
 include/safe-ctype.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/safe-ctype.h b/include/safe-ctype.h
index a3cb1858efc..843ba98571c 100644
--- a/include/safe-ctype.h
+++ b/include/safe-ctype.h
@@ -117,9 +117,16 @@ extern const unsigned char  _sch_tolower[256];
    detecting that ctype.h has been included.  But this was causing
    trouble as ctype.h might get indirectly included as a result of
    including another system header (for instance gnulib's stdint.h).
-   So we include ctype.h here and then immediately redefine its macros.  */
+   So we include ctype.h here and then immediately redefine its macros.
+   When compiling in C++ mode, aldo add <locale> which also defines
+   is* functions.
+*/
 
 #include <ctype.h>
+#ifdef __cplusplus
+#include <locale>
+#endif
+
 #undef isalpha
 #define isalpha(c) do_not_use_isalpha_with_safe_ctype
 #undef isalnum
-- 
2.40.0.634.g4ca3ef3211-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] safe-ctype.h: Fix building with latest libc++
  2023-04-13 19:44 [PATCH] safe-ctype.h: Fix building with latest libc++ Manoj Gupta
@ 2023-04-14 13:29 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-04-14 13:29 UTC (permalink / raw)
  To: Manoj Gupta via Gdb-patches; +Cc: Manoj Gupta

>>>>> Manoj Gupta via Gdb-patches <gdb-patches@sourceware.org> writes:

> Latest libc++[1] causes transitive include to <locale> when
> <mutex> or <thread> header is included. This causes
> gdb to not build[2] since <locale> 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 <locale> internally when
> building in C++ mode to avoid build errors.

> [1]: https://reviews.llvm.org/D144331
> [2]: https://issuetracker.google.com/issues/277967395
> ---
>  include/safe-ctype.h | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

This file is canonically maintained in gcc, so changes have to go there
first.

Alternatively you could perhaps change gdbsupport/gdb-safe-ctype.h,
though that might require fixing up the odd #include elsewhere.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-14 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 19:44 [PATCH] safe-ctype.h: Fix building with latest libc++ Manoj Gupta
2023-04-14 13:29 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).