Enable nullptr C++ keyword support

extras-nullptr

Purpose/History

For many years C++ had an embarrassment of not having a keyword to designate a null pointer. C++11 has eliminated that embarrassment with the nullptr keyword. C++'s strong type checking makes C's NULL macro almost useless in expressions.

As compilers not supportign C++11 do not have it, you can add it by including this into the header of any C++ code file:

1
2
3
#if _MSC_VER < 1600 //MSVC version <8
     #include "nullptr_emulation.h"
#endif

The explanation & code is from here https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr

Requirements

  1. A x86 version of Windows 2003 / XP SP1 with source code available: see https://rentry.co/build-win2k3
  2. \base\extras folder - where (global) common .c/.h files are stored

Changes

Add the following nullptr_emulation.h under the \base\extras\include folder:

const // It is a const object...
class nullptr_t 
{
  public:
    template<class T>
    inline operator T*() const // convertible to any type of null non-member pointer...
    { return 0; }

    template<class C, class T>
    inline operator T C::*() const   // or any type of null member pointer...
    { return 0; }

  private:
    void operator&() const;  // Can't take address of nullptr

} nullptr = {};
Edit
Pub: 19 Nov 2020 20:10 UTC
Edit: 19 Nov 2020 21:23 UTC
Views: 5136