title: Bit Shifts on a C Pointer?
body: <p>I'm in the middle of this C project that I wish to make very memory efficient.  In several cases, I am using the void *s of a dynamic array structure I wrote in order to hold bits.  I wish to use all 64 (in this case) bits.</p>
  
  <p>I soon realized that you cannot actually do any bit manipulation on a pointer.  So my solution was the following:</p>
  
  <pre><code>void *p;
  ((unsigned long)p) &lt;&lt; 4;
  ((unsigned long)p) &amp; 3;
  </code></pre>
  
  <p>This gets the job done, but only because on my computer, longs and pointers are equal in size.  Will this be the case in all (or most) architectures?</p>
  
  <p>And my real question: <strong>Is there a more correct way to do bit manipulation on a pointer?</strong>  I had thought that this approach was somewhat common in C (packing bits into a void *), but I could be mistaken...</p>