title: When should I use UINT32_C(), INT32_C(),... macros in C?
body: <p>I switched to fixed-length integer types in my projects mainly because they help me think about integer sizes more clearly when using them. Including them via <code>#include &lt;inttypes.h&gt;</code> also includes a bunch of other macros like the printing macros <code>PRIu32</code>, <code>PRIu64</code>,...</p>
  
  <p>To assign a constant value to a fixed length variable I can use macros like <code>UINT32_C()</code> and <code>INT32_C()</code>. I started using them whenever I assigned a constant value.</p>
  
  <p>This leads to code similar to this:</p>
  
  <pre><code>uint64_t i;
  for (i = UINT64_C(0); i &lt; UINT64_C(10); i++) { ... }
  </code></pre>
  
  <p>Now I saw several examples which did not care about that. One is the <code>stdbool.h</code> include file:</p>
  
  <pre><code>#define bool    _Bool
  #define false   0
  #define true    1
  </code></pre>
  
  <p><code>bool</code> has a size of 1 byte on my machine, so it does not look like an <code>int</code>. But <code>0</code> and <code>1</code> should be integers which should be turned automatically into the right type by the compiler. If I would use that in my example the code would be much easier to read:</p>
  
  <pre><code>uint64_t i;
  for (i = 0; i &lt; 10; i++) { ... }
  </code></pre>
  
  <p>So when should I use the fixed length constant macros like <code>UINT32_C()</code> and when should I leave that work to the compiler(I'm using GCC)? What if I would write code in MISRA C?</p>