Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: u8"" c11 c23 Date: Mon, 15 Dec 2025 14:27:26 -0800 Organization: None to speak of Lines: 33 Message-ID: <87ldj3tm7l.fsf@example.invalid> References: <10d5vck$3kufd$1@dont-email.me> <875xc9p674.fsf@example.invalid> <86h5trtv72.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 15 Dec 2025 22:27:27 +0000 (UTC) Injection-Info: dont-email.me; posting-host="1c4637fb3b5663b94c1d68a6155d6aa3"; logging-data="2355630"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qtx/G/Lm9cC81yJ5CjGfs" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:ogtFNO2WAdR5NcAxbKRHN7LNGMc= sha1:nGYn3bXpbX73mApwXBhzIody1dg= Xref: csiph.com comp.lang.c:395827 Tim Rentsch writes: > Keith Thompson writes: [...] >> The header was introduced in C99. In C99, C11, and C17, >> that header defines char16_t and char32_t. C23 introduces char8_t. >> >> There doesn't seem to be any way, other than checking the value of >> __STDC_VERSION__ to determine whether char8_t is defined or not. >> There are not *_MIN or *_MAX macros for these types, either in >> or in . A test program I just wrote would have >> been a little simpler if I could have used `#ifdef CHAR8_MAX`. [...] > Since C23 defines char8_t to be the same type as unsigned char, > it seems better to just define it when it isn't there: > > #include > > #if CHAR_BIT == 8 && __STDC_VERSION__ < 202311 > typedef unsigned char char8_t; > #endif Yes. And the test for CHAR_BIT may not be necessary, depending on the programmer's intent. char8_t is the same type as unsigned char even if CHAR_BIT > 8. Similarly, char16_t and char32_t are the same type as uint_least16_t and uint_least32_t, respectively. But before C23, u8"a" is a syntax error. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */