]> git.ipfire.org Git - thirdparty/systemd.git/commit
macro: Introduce UTF8() macro to define UTF-8 string literal
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 16 Mar 2025 00:31:43 +0000 (09:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 16 Mar 2025 01:15:24 +0000 (10:15 +0900)
commite193378d327e20dfa7778e613c8cd16817afbd2b
treeb4f7430a9a3cf2c880f4b3ace50fa17ad5c7c878
parent27cc77b746c54036c5d0d33ac476ee176c95003a
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.
src/basic/glyph-util.c
src/fundamental/macro-fundamental.h
src/hostname/hostnamectl.c
src/shared/qrcode-util.c
src/test/test-memstream-util.c