“You should really try to avoid using
NULL if possible and instead use
nullptr. It’s a lot safer if only
because you’re not checking against a
number (zero) - and it’s part of the
C++ language as of C++11 (which is
required by Rocket in any case!).”
#My Question
I was wondering if NULL in UE4 C++ still uses the actual macro, or if Epic has done this definition somewhere:
#define NULL nullptr
#Summary
Anyone with any comments on NULL vs nullptr, feel free to post.
I am not taking a stance on this, I am asking for more info
Though I do want to say, Thanks Neil for bringing this to my attention!
To answer your question, I think NULL is a Microsoft thing; IIRC it’s defined in Windows.h, which is probably getting included somewhere along the line.
I doubt it’s #defined anywhere. It’s part of C++ now.
nullptr should be used instead of the
C-style NULL macro in all cases. One
exception to this is that nullptr in
C++/CX builds (such as for Xbox One)
is actually the managed null reference
type. It is mostly compatible with
nullptr from native C++ except in its
type and some template instantiation
contexts, and so you should use the
TYPE_OF_NULLPTR macro instead of the
more usual decltype(nullptr) for
compatibility.
This is an old thread, but I thought I’d mention that as of 4.25.3, the Third Person Template from Epic still uses !=NULL repeatedly in the character CPP
If that’s not a good practice, they should probably update their code samples to keep people from misunderstanding it.