|
Message-ID: <20230524142201.GW4163@brightrain.aerifal.cx> Date: Wed, 24 May 2023 10:22:01 -0400 From: Rich Felker <dalias@...c.org> To: Jens Gustedt <Jens.Gustedt@...ia.fr> Cc: musl@...ts.openwall.com Subject: Re: [C23 divers headers 16/17] C23: add the nullptr_t type On Wed, Apr 19, 2023 at 08:42:15AM +0200, Jens Gustedt wrote: > This will only work with compilers that implement typeof and > nullptr. Currently this doesn't work for gcc but this will probably be > in gcc-13. Therefore the version test uses the future date of 202311L > which is the foreseen value for C23 final. > > For clang there are better feature test macros, namely > __is_identifier(nullptr) can be used to test if nullptr is an > identifier or a keyword. In particular, this feature now seems to work > with clang 16.0.2. > --- > include/stddef.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/include/stddef.h b/include/stddef.h > index 09be5fb6..e4d6b2ef 100644 > --- a/include/stddef.h > +++ b/include/stddef.h > @@ -26,4 +26,14 @@ > > #define unreachable() __builtin_unreachable() > > +#if __STDC_VERSION__ >= 202311L > +typedef typeof(nullptr) nullptr_t; > +#else > +#if __clang__ > +#if !__is_identifier(nullptr) > +typedef typeof(nullptr) nullptr_t; > +#endif > +#endif > +#endif > + > #endif > -- > 2.34.1 nullptr_t is not defined pre-C23 so the __clang__ branch shouldn't be there. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.