title: C++ casting a struct to std::vector<char> memory alignment
body: <p>I'm trying to cast a struct into a char vector.
  I wanna send my struct casted in std::vector throw a UDP socket and cast it back on the other side. Here is my struct whith the PACK attribute.</p>
  
  <pre><code>#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
  PACK(struct Inputs
  {
      uint8_t structureHeader;
      int16_t x;
      int16_t y;
      Key inputs[8];
  });
  </code></pre>
  
  <p>Here is test code:</p>
  
  <pre><code>auto const ptr = reinterpret_cast&lt;char*&gt;(&amp;in);
  std::vector&lt;char&gt; buffer(ptr, ptr + sizeof in);
  //send and receive via udp
  Inputs* my_struct = reinterpret_cast&lt;Inputs*&gt;(&amp;buffer[0]);
  </code></pre>
  
  <p>The issue is:
  All works fine except my uint8_t or int8_t.
  I don't know why but whenever and wherever I put a 1Bytes value in the struct, 
  when I cast it back the value is not readable (but the others are)
  I tried to put only 16bits values and it works just fine even with the 
  maximum values so all bits are ok.</p>
  
  <p>I think this is something with the alignment of the bytes in the memory but i can't figure out how to make it work.</p>
  
  <p>Thank you.</p>