Sujet : Re: question about nullptr
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 08. Jul 2024, 21:32:38
Autres entêtes
Organisation : None to speak of
Message-ID : <87a5iry68p.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Gnus/5.13 (Gnus v5.13)
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.comvoid Void(void) { Void(); } /* The recursive call of the void */