title: Casting Void Pointer to Struct
body: <p>Suppose we have a struct "message_t":</p>
  
  <pre><code>message_t *msg;
  </code></pre>
  
  <p>If a function returns a void pointer can we simply assign the address to msg, or do we need to cast the pointer?:</p>
  
  <pre><code>void *data;
  msg = data;
  </code></pre>
  
  <p>I've seen cases where "data" would be cast to <code>message_t</code>, however this doesn't seem entirely necessary, so in which situations would you do this?</p>
  
  <p>Surely the pointer type (message_t) should be enough to tell the compiler how to dereference the pointer (i.e. how many bytes the first variable in the struct needs, etc).</p>
  
  <p>Let me know if my question isn't clear.</p>