title: C/C++ packing signed char into int
body: <p>I have need to pack four signed bytes into 32-bit integral type.
  this is what I came up to:</p>
  
  <pre><code>int32_t byte(int8_t c) { return (unsigned char)c; }
  
  int pack(char c0, char c1, ...) {
    return byte(c0) | byte(c1) &lt;&lt; 8 | ...;
  }
  </code></pre>
  
  <p>is this a good solution? Is it portable (not in communication sense)?
  is there a ready-made solution, perhaps boost?</p>
  
  <p>issue I am mostly concerned about is bit order when converting of negative bits from char to int.  I do not know what the correct behavior should be.</p>
  
  <p>Thanks</p>