title: Is there an elegant way to force the comparison of two constants?
body: <p>As we all know, the following code will be optimized by all sensible compilers:</p>
  
  <pre><code>const int a = 3;
  const int b = 42;
  
  if (a == b)
  {
      do_something();
  }
  </code></pre>
  
  <p>If the two constants are the same, the <code>if</code> is omitted and the function always called, if they are different, the whole block is omitted.</p>
  
  <p>However, there can be situations where it is important to NOT optimize this code, as the program itself can be modified before it is run. E.g. the binary sits in flash memory and can be accessed by an external program, and of course the adresses of the two <code>const</code>s are fixed. (makes sense in embedded).</p>
  
  <p>I'm thinking of using <code>#pragma</code>, but that is not part of the C standard.</p>
  
  <p>Another way would be to use <code>const volatile</code>. Is that guaranteed to work on all standard-compliant compilers?</p>