[binutils-gdb] [gdb/build] Fix cli/cli-style.c build error with C++20
Tom de Vries via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f33422af6d81c623871f1407e2fce0794e90739a commit f33422af6d81c623871f1407e2fce0794e90739a Author: Tom de Vries <[email protected]> Date: Thu Aug 13 05:23:09 2026 +0200 [gdb/build] Fix cli/cli-style.c build error with C++20 PR build/34514 reports for a C++20 build: ... cli/cli-style.c:457:37: error: conversion from ‘const char8_t [8]’ to \ non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} \ requested 457 | static std::string warning_prefix = u8"\u26A0\uFE0F "; | ^~~~~~~~~~~~~~~~~ ... The u8 literal is char[] until C++20, but char8_t[] since C++20. Fix this by using a reinterpret_cast<const char *>. Tested by rebuilding using GCC 15.3.0, with and without -std=c++20. Approved-By: Simon Marchi <[email protected]> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34514 Diff: --- gdb/cli/cli-style.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index 60c00acdf43..5c26519c6d7 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -454,7 +454,8 @@ no_emojis () - 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 = u8"\u26A0\uFE0F "; +static std::string warning_prefix + = reinterpret_cast<const char *> (u8"\u26A0\uFE0F "); /* Implement 'show style warning-prefix'. */ @@ -479,7 +480,8 @@ print_warning_prefix (ui_file *file) - u274C: Cross Mark: ❌ No VS16 is needed because the default presentation for Cross Mark is "Emoji". */ -static std::string error_prefix = u8"\u274C "; +static std::string error_prefix + = reinterpret_cast<const char *> (u8"\u274C "); /* Implement 'show style error-prefix'. */