macro: Introduce UTF8() macro to define UTF-8 string literal
C23 changed char8_t from char to unsigned char, hence assigning a u8 literal
to const char* emits pointer sign warning, e.g.
========
../src/shared/qrcode-util.c: In function ‘print_border’:
../src/shared/qrcode-util.c:16:34: warning: pointer targets in passing argument 1 of ‘fputs’ differ in signedness [-Wpointer-sign]
16 | #define UNICODE_FULL_BLOCK u8"█"
| ^~~~~
| |
| const unsigned char *
../src/shared/qrcode-util.c:65:39: note: in expansion of macro ‘UNICODE_FULL_BLOCK’
65 | fputs(UNICODE_FULL_BLOCK, output);
| ^~~~~~~~~~~~~~~~~~
========
This introduces UTF8() macro, which define u8 literal and casts to consth char*,
then rewrites all u8 literal definitions with the macro.
With this change, we can build systemd with C23.
This commit is contained in:
@@ -70,21 +70,21 @@ typedef struct StatusInfo {
|
||||
|
||||
static const char* chassis_string_to_glyph(const char *chassis) {
|
||||
if (streq_ptr(chassis, "laptop"))
|
||||
return u8"💻"; /* Personal Computer */
|
||||
return UTF8("💻"); /* Personal Computer */
|
||||
if (streq_ptr(chassis, "desktop"))
|
||||
return u8"🖥️"; /* Desktop Computer */
|
||||
return UTF8("🖥️"); /* Desktop Computer */
|
||||
if (streq_ptr(chassis, "server"))
|
||||
return u8"🖳"; /* Old Personal Computer */
|
||||
return UTF8("🖳"); /* Old Personal Computer */
|
||||
if (streq_ptr(chassis, "tablet"))
|
||||
return u8"具"; /* Ideograph tool, implement; draw up, write, looks vaguely tabletty */
|
||||
return UTF8("具"); /* Ideograph tool, implement; draw up, write, looks vaguely tabletty */
|
||||
if (streq_ptr(chassis, "watch"))
|
||||
return u8"⌚"; /* Watch */
|
||||
return UTF8("⌚"); /* Watch */
|
||||
if (streq_ptr(chassis, "handset"))
|
||||
return u8"🕻"; /* Left Hand Telephone Receiver */
|
||||
return UTF8("🕻"); /* Left Hand Telephone Receiver */
|
||||
if (streq_ptr(chassis, "vm"))
|
||||
return u8"🖴"; /* Hard disk */
|
||||
return UTF8("🖴"); /* Hard disk */
|
||||
if (streq_ptr(chassis, "container"))
|
||||
return u8"☐"; /* Ballot Box */
|
||||
return UTF8("☐"); /* Ballot Box */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user