Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/build] Add warning_prefix_default/error_prefix_default constants
@ 2026-08-13 11:51 Tom de Vries
  2026-08-21 15:18 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-08-13 11:51 UTC (permalink / raw)
  To: gdb-patches

Post-commit review of commit f33422af6d8 ("[gdb/build] Fix cli/cli-style.c
build error with C++20") pointed out the need for a comment for a
reinterpret_cast [1].

While reviewing the comment in gdb/top.c for bd_heavy_horizontal et al, I
realized I could use the same style:
...
static const char bd_heavy_horizontal[] = u8"\u2501";
...
and get rid of the reinterpret_cast.

Add warning_prefix_default and error_prefix_default constants, and copy
the comment from gdb/top.c.

Tested on x86_64-linux.

[1] https://sourceware.org/pipermail/gdb-patches/2026-August/229421.html
---
 gdb/cli/cli-style.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 5c26519c6d7..cc22b861ca0 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -449,13 +449,26 @@ no_emojis ()
   emoji_styling = AUTO_BOOLEAN_FALSE;
 }
 
-/* Emoji warning prefix:
+/* Emoji warning prefix default:
    - u26A0: Warning Sign: ⚠
    - uFE0F: Variation Selector-16 (VS16)
    The VS16 forces "Emoji" presentation.  It is needed because the default
-   presentation for Warning Sign is "Text".  Together, we get: ⚠️ .  */
-static std::string warning_prefix
-  = reinterpret_cast<const char *> (u8"\u26A0\uFE0F ");
+   presentation for Warning Sign is "Text".  Together, we get: ⚠️ .
+
+   Emoji error prefix default:
+   - u274C: Cross Mark: ❌
+   No VS16 is needed because the default presentation for Cross Mark is
+   "Emoji".
+
+   UTF-8 string literals have type:
+   - const char[N]    (until C++20), or
+   - const char8_t[N] (since C++20).
+   Assign them to a variable to stabilize the type.  */
+static const char warning_prefix_default[] = u8"\u26A0\uFE0F ";
+static const char error_prefix_default[] = u8"\u274C ";
+
+/* Emoji warning prefix.  */
+static std::string warning_prefix = warning_prefix_default;
 
 /* Implement 'show style warning-prefix'.  */
 
@@ -476,12 +489,8 @@ print_warning_prefix (ui_file *file)
     gdb_puts (warning_prefix.c_str (), file);
 }
 
-/* Emoji error prefix:
-   - u274C: Cross Mark: ❌
-   No VS16 is needed because the default presentation for Cross Mark is
-   "Emoji".  */
-static std::string error_prefix
-  = reinterpret_cast<const char *> (u8"\u274C ");
+/* Emoji error prefix.  */
+static std::string error_prefix = error_prefix_default;
 
 /* Implement 'show style error-prefix'.  */
 

base-commit: f33422af6d81c623871f1407e2fce0794e90739a
-- 
2.51.0


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

end of thread, other threads:[~2026-08-21 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-13 11:51 [PATCH] [gdb/build] Add warning_prefix_default/error_prefix_default constants Tom de Vries
2026-08-21 15:18 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox