title: Assign result of sizeof() to ssize_t
body: <p>It happened to me that I needed to compare the result of <code>sizeof(x)</code> to a <code>ssize_t</code>.</p>
  
  <p>Of course GCC gave an error (lucky me (I used <code>-Wall -Wextra -Werror</code>)), and I decided to do a macro to have a signed version of <code>sizeof()</code>.</p>
  
  <pre><code>#define ssizeof (ssize_t)sizeof
  </code></pre>
  
  <p>And then I can use it like this:</p>
  
  <pre><code>for (ssize_t i = 0; i &lt; ssizeof(x); i++)
  </code></pre>
  
  <p>The problem is, do I have any guarantees that <code>SSIZE_MAX &gt;= SIZE_MAX</code>? I imagine that sadly this is never going to be true.</p>
  
  <p>Or at least that <code>sizeof(ssize_t) == sizeof(size_t)</code>, which would cut half of the values but would still be close enough.</p>
  
  <p>I didn't find any relation between <code>ssize_t</code> and <code>size_t</code> in the POSIX documentation.</p>
  
  <p>Related question:</p>
  
  <p><a href="https://stackoverflow.com/q/55303654/6872717">What type should be used to loop through an array?</a></p>