title: Preventing C integer overflow
body: <p>I have some code in a function which will change/update values with the increment/decrement operator. For example:</p>
  
  <pre><code>static void update_value(char op)
  {
      if (op == '+')
          value++;    // uint32_t global value
      else
          value--;
  }
  </code></pre>
  
  <p>The function does not check whether we've gone over/under max/min values. So the caller can call it 20 times when value is say 16. resulting in 2^32 - 1 - 4.</p>
  
  <p>I'd like to guard against that but I would like to use standard library constants. I remember there was a size_t (or similar) variable that would represent the largest number that a uint32_t can hold.</p>
  
  <p>I can't remember the exact constants nor the header where they were defined. Any help?</p>