title: Why is C++'s NULL typically an integer literal rather than a pointer like in C?
body: <p>I've been writing C++ for many years, using <code>nullptr</code> for null pointers. I also know C, whence NULL originates, and remember that it's the constant for a null pointer, with type <code>void *</code>.</p>
  <p>For reasons, I've had to use <code>NULL</code> in my C++ code for something. Well, imagine my surprise when during some template argument deduction the compiler tells me that my NULL is really a ... long. So, I double-checked:</p>
  <pre><code>#include &lt;type_traits&gt;
  #include &lt;cstddef&gt;
  
  static_assert(not std::is_same&lt;decltype(NULL), long&gt;::value, &quot;NULL is long ???&quot;);
  </code></pre>
  <p>And indeed, the static assertion fails (with GCC and with Clang).</p>
  <p>I checked on <a href="https://en.cppreference.com/w/cpp/types/NULL" rel="noreferrer">cppreference.com</a>, and sure enough (C++11 wording):</p>
  <blockquote>
  <p>The macro NULL is an implementation-defined null pointer constant, which may be
  an integer literal with value zero, or a prvalue of type <code>std::nullptr_t</code>.</p>
  </blockquote>
  <p>Why does this make sense? In itself, and in light of the incompatibility of C?</p>