How SerenityOS declares ssize_t
I would do it like this:<p><pre><code>  #if SIZEOF_SIZE_T == 8
  typedef int64_t ssize_t
  #elif SIZEOF_SIZE_T == 4
  typedef int32_t ssize_t
  #elif SIZEOF_SIZE_T == 2 &#x2F;&#x2F; LOL
  typedef int16_t ssize_t
  #else
  #error port me!
  #endif
</code></pre>
SIZEOF_SIZE_T can be obtained using a script which compiles a test program without executing it.<p>Over they years I used more than one approach, settling on this one:<p><a href="https:&#x2F;&#x2F;www.kylheku.com&#x2F;cgit&#x2F;txr&#x2F;tree&#x2F;configure?id=1f902ca63eba9071da5d1da2e861fe49028d32b4#n1487" rel="nofollow">https:&#x2F;&#x2F;www.kylheku.com&#x2F;cgit&#x2F;txr&#x2F;tree&#x2F;configure?id=1f902ca63...</a><p>Here, in the test program, a DEC macro has been defined which given a constant expression, produces two decimal digits  as the initializer for a two-character array. For instance:<p><pre><code>   DEC(42) -&gt; { &#x27;4&#x27;, &#x27;2&#x27; }  &#x2F;&#x2F; not exactly: character constants are not used
</code></pre>
With this trick we can use DEC(sizeof (size_t)) to get a value like { &#x27; &#x27;, &#x27;8&#x27; } into the portion of some character data, which we can prefix with an identifying string we can look for, like:<p><pre><code>   SIZEOF_SIZE_T= 8
</code></pre>
That we can basically grep out.  In my configure script, this data is extracted, spaces are removed from it, and it&#x27;s evaluated directly as shell assignments, so then the values are available in shell variables.