Post Reply 
Thread Rating:
  • 10 Vote(s) - 3.1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++11 standard and nullptr
Author Message
jayands Offline
Junior Member

Posts: 2
Joined: Nov 2010
Reputation: 0
Post: #1
C++11 standard and nullptr


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 ( ). I've noticed that sometimes this occurs in the C++ source:
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!):
Quote: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++.
08-10-2016 05:29 AM
Find all posts by this user Quote this message in a reply
Post Reply 

Forum Jump:

User(s) browsing this thread: 1 Guest(s)

 Quick Theme: