title: How to force GCC compiler to calculate constant values at compile time?
body: <p>I have the following code (CPU Atmel AVR ATmega64A):</p>
  
  <pre><code>#define UO_ADC1023  265
  #define UREF_180V   (1023*180/UO_ADC1023)
  ....
  if(ADC &gt; UREF180) {do_something();}
  </code></pre>
  
  <p>This should evaluate <code>UREF_180V</code> as 694.87... and than this value should be rounded (better) to 695 or floored (poorer) to 694 to be compared to ADC register.</p>
  
  <p>However I have <code>integer overflow</code> warning at compile. As per this I suppose that compiler generating code which calculates <code>(1023*180/UO_ADC1023)</code> at the run time which is very bad in my case.</p>
  
  <p>I'd like to avoid to calculate those constants by my self (<code>#define UREF_180V 695</code> in this case I could be sure that they are really literals) to make the code more flexible and readable. I'd like also to be able to check those values after the compiler.</p>
  
  <p>So the questions are:</p>
  
  <ol>
  <li><p>Is there any possibility to force GCC compiler to calculate such constants at compile time?</p></li>
  <li><p>How to check this calculated value?</p></li>
  </ol>