Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is no <code>LPVOID</code> type in C, it's a Windows thing.</p> <p>And the reason those sort of things exists is so that the underlying types can change from release to release without affecting your source code.</p> <p>For example, let's say early versions of Microsoft's C compiler had a 16-bit <code>int</code> and a 32-bit <code>long</code>. They could simply use:</p> <pre><code>typedef long INT32 </code></pre> <p>and, voila, you have your 32-bit integer type.</p> <p>Now let's go forward a few years to a time where Microsoft C uses a 32-bit <code>int</code> and a 64-bit <code>long</code>. In order to still have your source code function correctly, they simply change the <code>typedef</code> line to read:</p> <pre><code>typedef int INT32 </code></pre> <p>This is in contrast to what you'd have to do if you were using <code>long</code> for your 32-bit integer types. You'd have to go through <em>all</em> your source code and ensure that you changed your own definitions.</p> <p>It's much cleaner from a compatibility viewpoint (compatibility between different versions of Windows) to use Microsoft's data types.</p> <p>In answer to your specific question, it's probably okay to use <code>void*</code> instead of <code>LPVOID</code> <em>provided the definition of</em> <code>LPVOID</code> <em>is not expected to change.</em></p> <p>But I wouldn't, just in case. You never know if Microsoft may introduce some different way of handling generic pointers in future that would change the definition of <code>LPVOID</code>. You don't really lose anything by using Microsoft's type but you <em>could</em> be required to do some work in future if they change the definition and you've decided to use the underlying type.</p> <p>You may not think pointers would be immune to this sort of change but, in the original 8088 days when Windows was created, there were all sorts of weirdness with pointers and memory models (tiny, small, large, huge et al) which allowed pointers to be of varying sizes even within the same environment.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload