Re:Essential C (2003) [pdf]
by andi999 on Wednesday September 02, 2020 @07:42PM
(#24359466)
size_t is unsigned? Since when?
[ Parent
| on HN ]
It always has been. C89, 4.1.5[1]:
> The type are [...] size_t which is the unsigned integral type of the result of the sizeof operator
(Emphasis mine.)
Couldn't find an online version of the C standard with links to parts of it, but here's one for C++: http://eel.is/c++draft/support.types#layout-3
> The type size_t is an implementation-defined unsigned integer type that is large enough to contain the size in bytes of any object ([expr.sizeof]).
Yes. ssize_t is signed.
ssize_t should never be used.
It's not guaranteed to have a full negative range, only to be able to represent -1.
Use ptrdiff_t as a signed size type.
Re:Essential C (2003) [pdf]
by AbacusAvenger on Thursday September 03, 2020 @04:02AM
(#24361798)
Out of curiosity, do you know of any implementations where ssize_t has that kind of range limitation?