From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20896 invoked from network); 24 May 2023 14:22:19 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 24 May 2023 14:22:19 -0000 Received: (qmail 20005 invoked by uid 550); 24 May 2023 14:22:16 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 19918 invoked from network); 24 May 2023 14:22:14 -0000 Date: Wed, 24 May 2023 10:22:01 -0400 From: Rich Felker To: Jens Gustedt Cc: musl@lists.openwall.com Message-ID: <20230524142201.GW4163@brightrain.aerifal.cx> References: <9985ac5610d2e36d01032e1685ca3d629fccac64.1684932861.git.Jens.Gustedt@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9985ac5610d2e36d01032e1685ca3d629fccac64.1684932861.git.Jens.Gustedt@inria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [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