From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14374 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Define NULL as __null in C++ mode when using GCC or Clang. Date: Wed, 10 Jul 2019 10:46:04 +0200 Message-ID: <20190710084604.GJ21055@port70.net> References: <20190709193826.GR1506@brightrain.aerifal.cx> <20190710020357.GI21055@port70.net> <871ryycs9n.fsf@oldenburg2.str.redhat.com> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="173229"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-14390-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 10 10:46:20 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hl8F2-000ivI-79 for gllmg-musl@m.gmane.org; Wed, 10 Jul 2019 10:46:20 +0200 Original-Received: (qmail 9423 invoked by uid 550); 10 Jul 2019 08:46:17 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 9401 invoked from network); 10 Jul 2019 08:46:16 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <871ryycs9n.fsf@oldenburg2.str.redhat.com> Xref: news.gmane.org gmane.linux.lib.musl.general:14374 Archived-At: * Florian Weimer [2019-07-10 08:34:12 +0200]: > * Szabolcs Nagy: > > it is clear that 0L is a conforming definition for all > > conforming c++ compilers. > > > > it is less clear if __null is so in all compilers that > > define __GNUC__. > > Why wouldn't something like this be valid for current C++ versions? if you aim for current c++ only then you need even more ifdefs (#if __cplusplus > ..). > static inline constexpr decltype(nullptr) __null{}; > #define NULL __null > > I don't see a requirement that NULL must be an expression that can be > evaluated by the preprocessor. c++03 requires an integral const expr., integral const expr must be usable in #if. c++11 quietly changed that. in this case that works out though: undefined identifiers are 0 in #if, so #if __null works as expected. stringification is probably not a valid argument.