Page 1 of 1

C++11 standard and nullptr

Posted: Tue Aug 09, 2016 3:29 pm
by jayands

Hello,

 

There are a lot of instances that use NULL
as opposed to the shiny and new nullptr
. The thing is, though, NULL
is typically defined as the number 0, due to C legacy stuff (http://en.cppreference.com/w/cpp/types/NULL ). I've noticed that sometimes this occurs in the C++ source:

Code: Select all

static int(ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzCloseFunc)(gzFile) = NULL;

from what I'm seeing, you probably want nullptr
, but that could just as easily need to eval to literal zero, and what's more, it's not guaranteed to be either.

 

And according to Sublime Text, NULL
shows up a lot (this is just *.cpp files!):

1573 matches across 129 files

 

So, besides using nullptr
or literal zero in new code, how do you want to handle this? A bunch of individual file commits, or one big overhaul? Also, I personally beleve the C code should still use NULL
, because it's defined as a void*
there, but that's illegal in C++.


Re: C++11 standard and nullptr

Posted: Fri Mar 27, 2020 3:11 am
by ZachBacon

I know I'm very very late getting to this, chances are we won't be using newer standards in the core due to the fact we want to keep the libretro frontend to support older consoles such as the wii etc