title: Is casting an integer value to a void* an often used paradigm in callbacks?
body: <p>Rather than sending an actual pointer to a value, the value is cast to a pointer. I found these examples in the GUI interface code of a GTK program.</p>
  
  <pre><code>g_signal_connect (pastebutton[pane],
                    "clicked",
                    G_CALLBACK(on_paste_button_pressed),
                    (void*)((long)pane&lt;&lt;4));
  </code></pre>
  
  <p>In the above example, I am referring to the last parameter of <code>g_signal_connect</code>. When <code>on_paste_button_pressed</code> is called by GTK2, <code>on_paste_button_pressed</code> casts the <code>user_data</code> void pointer back like so:</p>
  
  <pre><code>int pane = ((long)user_data) &gt;&gt; 4;
  </code></pre>
  
  <p>Actually, I added this particular example to the code, but I based it upon what was already there. I added the bit-shifting so as to avoid warnings about casting. The program itself has four panes containing quite a number of widgets, the copy and paste buttons allow you to copy all the values from one pane to another.</p>
  
  <p>Is this way of casting a value to a pointer address often used, and are there reasons why this should not be used?</p>
  
  <p><strong>edit:</strong></p>
  
  <p>The cast from an integer to a void pointer can also be achieved like so:</p>
  
  <pre><code>void* void_ptr = some_int - NULL;
  </code></pre>