title: Typecasting an integer to a character pointer in C
body: <p>I have a function <code>uint8_t EE_Write(uint8_t addr, uint8_t len, uint8_t * buf)</code> that takes a pointer to some data that it will write to memory, and a <code>uint16_t myword</code> that I want to give it.  The basic</p>
  
  <pre><code>EE_Write(0,sizeof(myword),&amp;myword);
  </code></pre>
  
  <p>gives me the compiler warning "Indirection to different types ('unsigned int *const ' instead of 'unsigned char *const ')"  Even when I typecast the word (int) to a byte (char), I received the exact same warning (and no amount of grouping with parenthesis helped).</p>
  
  <pre><code>EE_Write(0,sizeof(myword),&amp;(uint8_t)myword);
  </code></pre>
  
  <p>Warnings go away with a union, but it's asinine to have to write it to another variable just to make the compiler happy.</p>
  
  <pre><code>union catbyte {
      uint16_t w;
      uint8_t b[2];
  };
  
  union catbyte mybytes;
  
  mybytes.w = myword;
  EE_Write(0,sizeof(myword),mybytes.b);
  </code></pre>