title: Casting struct into int
body: <p>Is there a clean way of casting a struct into an uint64_t or any other int, given that struct in &lt;= to the sizeof int?
  The only thing I can think of is only an 'ok' solution - to use unions. However I have never been fond of them.</p>
  
  <p>Let me add a code snippet to clarify:</p>
  
  <pre><code>typedef struct {
  uint8_t field: 5;
  uint8_t field2: 4;
  /* and so on... */
  }some_struct_t;
  
  some_struct_t some_struct;
  //init struct here
  
  uint32_t register;
  </code></pre>
  
  <p>Now how do i cast some_struct to capture its bits order in uint32_t register.</p>
  
  <p>Hope that makes it a bit clearer.</p>