Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb/build] Add warning_prefix_default/error_prefix_default constants
Date: Thu, 13 Aug 2026 13:51:53 +0200	[thread overview]
Message-ID: <20260813115154.2547573-1-tdevries@suse.de> (raw)

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


             reply	other threads:[~2026-08-13 11:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 11:51 Tom de Vries [this message]
2026-08-21 15:18 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260813115154.2547573-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox