In source files which I am using in my project, there is a comparison between ssize_t
and size_t
variables:
ssize_t sst;
size_t st;
if
Either will work fine as long as both values fit in the positive representable range of ssize_t
.
If either value doesn't, you could end up in trouble - check those cases before testing for equality:
if ((sst >= 0) && (st <= SSIZE_MAX) && (sst == (ssize_t)st))
{
...
}
(I'm sure the C++ people will recommend you avoid the C-style cast entirely - I have no doubt someone will comment or answer and let you know the right way to do that in C++.)