Deutsch   English   Français   Italiano  
<87a5iry68p.fsf@nosuchdomain.example.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: question about nullptr
Date: Mon, 08 Jul 2024 13:32:38 -0700
Organization: None to speak of
Lines: 28
Message-ID: <87a5iry68p.fsf@nosuchdomain.example.com>
References: <v6bavg$3pu5i$1@dont-email.me> <20240706054641.175@kylheku.com>
	<v6bfi1$3qn4u$1@dont-email.me> <l9ciO.7$cr5e.2@fx05.iad>
	<877cdyuq0f.fsf@bsb.me.uk> <2ckiO.19403$7Ej.4487@fx46.iad>
	<87plrpt4du.fsf@bsb.me.uk> <9bCiO.7108$sXW9.3805@fx41.iad>
	<877cdwu9s1.fsf@nosuchdomain.example.com>
	<zqSiO.13381$OXD2.9845@fx47.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Mon, 08 Jul 2024 22:32:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="83c91517b0a65a07e910cc6c3b2cc219";
	logging-data="1079458"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1987tMXN/4lKN6yFo+cAN78"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:OA9tscS5/6DMuRN1R648XeeCMrg=
	sha1:v4ecHLBavc7wYKyAFwf5yUVoOv0=
Bytes: 2234

scott@slp53.sl.home (Scott Lurndal) writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
[...]
>>In C23, I'll use nullptr rather than NULL *if* I don't care about
>>portability to pre-C23 compilers.  (I use nullptr in C++.)
>
> I haven't made the transition to nullptr in C++ yet, too many years
> of using NULL and code bases that need to compile with older
> standards (pre C++11, until very recently) - granted one might
>
> #define nullptr (void *)NULL

I've thought about doing something like that, but I haven't had the
opportunity so far, and I'm not sure I would.

I might write something like:

    #if __STDC_VERSION__ < 202311L
    #define nullptr ((void*)NULL)
    #endif

But if I had to compile with both pre-C23 and newer compilers, I'd be
more likely to just use NULL (with a cast where necessary).  I'd
consider the `#define nullptr` trick if pre-C23 compilers were rare.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */