title: Explicit cast of pointer to long long
body: <p>I need to cast a pointer to a long long, and would prefer to do it in a way that gcc doesn't complain on either 32 or 64-bit architectures about converting pointer to ints of different size.  And before anyone asks, yes, I know what I'm doing, and I know what I'm casting to -- my specific use case is wanting to send a stack trace (the pointers themselves being the subject here) over the network when an application error occurs, so there is no guarantee the sender and receiver will have the same word size.  I've therefore built a struct holding the message data with, among other entries, an array of "unsigned long long" values (guaranteed minimum 64-bits) to hold the pointers.  And yes, I know "long long" is not <em>guaranteed</em> to be <em>only</em> 64-bits, but all compilers I'm using for both source and destination implement it as 64-bits.  Because the header (and source) with the struct will be used on both architectures, "uintptr_t" doesn't seem like a workable solution (because, according to the definition in stdint.h, its size is architecture-dependent).</p>
  
  <p>I thought about getting tricky with anonymous unions, but this feels a little too hackish to me...I'm hoping there's a way with some double-cast magic or something to do this in C99 (since anonymous unions weren't standard until C11).</p>
  
  <p>EDIT:</p>
  
  <pre><code>typedef struct error_msg_t {
    int msgid;
    int len;
    pid_t pid;
    int si_code;
    int signum;
    int errno;
    unsigned long long stack[20];
    char err_msg[];
  } error_msg_t;
  ...
  void **stack;
  ...
  msg.msgid = ERROR_MSG;
  msg.len = sizeof(error_msg_t) + strlen(err_msg) + 1);
  msg.pid = getpid();
  ...
  for (i=0; i&lt;stack_depth; i++)
    msg.stack[i] = (unsigned long long)stack[i];
  </code></pre>
  
  <p>Warning (on a 32-bit compile) about casting to integer of different size occurs on the last line.</p>