title: Why is PDWord not ^DWORD?
body: <p>This program</p>
  
  <pre><code>{$APPTYPE CONSOLE}
  {$TYPEDADDRESS ON}
  
  uses
    Winapi.Windows;
  
  procedure Foo(P: PDWORD);
  begin
  end;
  
  procedure Bar;
  var
    dw: DWORD;
  begin
    Foo(@dw);
  end;
  
  begin
  end.
  </code></pre>
  
  <p>compiles in XE3, but does not in XE4, XE5, XE6 and XE7. The error is at</p>
  
  <pre><code>Foo(@dw);
  </code></pre>
  
  <pre>
  [dcc32 Error] E2010 Incompatible types: 'PDWORD' and 'Pointer'
  </pre>
  
  <p>This feels odd. So, after a bit of digging it seems that the issue is down to the definition of <code>PDWORD</code>. One might naturally think that it would be:</p>
  
  <pre><code>PDWORD = ^DWORD;
  </code></pre>
  
  <p>and indeed that is the case in XE3. In later versions we find this:</p>
  
  <pre><code>// Note: Not ^DWORD yet
  PDWORD = ^CppULongInt;
  </code></pre>
  
  <p>Odd. So, what is <code>CppULongInt</code>?</p>
  
  <pre><code>CppULongInt = type LongWord; 
  {$EXTERNALSYM CppULongInt 'unsigned long'} 
  {$OBJTYPENAME CppULongInt 'Bul' 'Gm'}
  </code></pre>
  
  <p>Then looking at the declaration for <code>DWORD</code> we find:</p>
  
  <pre><code>//NOTE: DWORD should really be CppULongInt
  DWORD = LongWord;
  </code></pre>
  
  <p>So, <code>CppULongInt</code> and <code>DWORD</code> are different types. Hence the compilation error.</p>
  
  <p>What's going on here? What is the purpose of <code>CppULongInt</code>? Why do the RTL designers appear to want to alias <code>DWORD</code> to <code>CppULongInt</code>. Is this change related to the x64 Windows C++ compiler based on LLVM? Am I the only person in the world that uses <code>{$TYPEDADDRESS ON}</code>? </p>
  
  <p>Note, that last question is rhetorical.</p>