It is the correct type on linux as well. Therefore, the approach suggested
by Cyrille is IMHO the best one: Change the type of nRead to ssize_t (note
the two s), and change the if-condition to
if (static_cast<size_t>(nRead) < buf.size() - 1) {
This is 100% safe: We know that nRead > 0 at the time the cast occurs, and
ssize_t has the same number of bits as size_t, and buf.size() returns
size_t, and buf.size() is never 0. The static_cast is better than a C-style
cast, since you can search for it, and it expresses what is wanted (C-style
casts could also be used to cast constness away etc).
Georg made a small type: The cast should be
> if (static_cast<ssize_t>(nRead) < buf.size() - 1) {
as mentioned earlier (two s). In general, though, I think it's better to
adapt the variable type such that type casts are not necessary. In this
case, "nRead" would be changed to ssize_t. Without looking at all the code,
I'm not sure if this is the best solution here (sometimes changing one
variable type requires many subsequent changes).
--
Regards,
Cyrille Artho - http://artho.com/
The major crimes throughout history, have been committed
not by individuals but by governments.
-- John Hospers