Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C over the years

Name: Anonymous 2015-07-24 1:45

Does anyone know why did the definitions of many functions in the C standard library got changed to return ssize_t instead of int? For instance read and write, both returning -1 in case of error, whilst all declarations of ssize_t I've seen are unsigned. What is this crazyness?

Name: Anonymous 2015-07-24 19:11

>>1,7-8
ssize_t literally stands for "signed size type".

I suspect the lack of any requirement that it be able to represent any value that can be represented by a size_t is a historical artifact. In the beginning, there was no ssize_t, everyone just used long instead. Hence, any functions that were subsequently redefined to use ssize_t have to use a type that is compatible with long, to avoid breaking existing applications. Since the POSIX standard also has no requirement that a long be able to represent all values that can be represented with a size_t, the standard is stuck at this impasse forever.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List