title: Ways to ASSERT expressions at build time in C
body: <p>I'm tidying up some older code that uses 'magic numbers' all over the place to set hardware registers, and I would like to use constants instead of these numbers to make the code somewhat more expressive (in fact they will map to the names/values used to document the registers).</p>
  
  <p>However, I'm concerned that with the volume of changes I might break the magic numbers. Here is a simplified example (the register set is more complex):</p>
  
  <pre><code>const short mode0 = 0;
  const short mode1 = 1;
  const short mode2 = 2;
  
  const short state0 = 0;
  const short state1 = 4;
  const short state2 = 8;
  </code></pre>
  
  <p>so instead of :</p>
  
  <pre><code>set_register(5);
  </code></pre>
  
  <p>we have:</p>
  
  <pre><code>set_register(state1|mode1);
  </code></pre>
  
  <p>What I'm looking for is a <strong>build time</strong> version of:</p>
  
  <pre><code>ASSERT(5==(state1|mode1));
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>@Christian, thanks for the quick response, I'm interested on a C / non-boost environment answer too because this is driver/kernel code.</p>