OS: Debian 9 (Linux 4.9)
Compiler: GCC 8.2
Currently I am including
(where size_t
is defined) and
Since version 5.9, the Linux man-pages document system data types, so that you can find this information easily in a centralized manner.
Just type man ssize_t:
ssize_t
Include: . Alternatively, , ,
, , , , ,
or .
Used for a count of bytes or an error indication. According to
POSIX, it shall be a signed integer type capable of storing val-
ues at least in the range [-1, SSIZE_MAX], and the implementa-
tion shall support one or more programming environments where
the width of ssize_t is no greater than the width of the type
long.
Glibc and most other implementations provide a length modifier
for ssize_t for the printf(3) and the scanf(3) families of func-
tions, which is z; resulting commonly in %zd or %zi for printing
ssize_t values. Although z works for ssize_t on most implemen-
tations, portable POSIX programs should avoid using it--for ex-
ample, by converting the value to intmax_t and using its length
modifier (j).
Conforming to: POSIX.1-2001 and later.
See also: read(2), readlink(2), readv(2), recv(2), send(2),
write(2)
See also the ptrdiff_t and size_t types in this page.
And later in the NOTES section of that same page:
NOTES
[...]
Conventions used in this page
[...]
In "Include", we first note the "primary" header(s) that define the
type according to either the C or POSIX.1 standards. Under "Alterna-
tively", we note additional headers that the standards specify shall
define the type.
If you just want ssize_t
, you should include
, which is its canonical header, and probably the lightest one that provides ssize_t
. However, it is provided by any of the headers documented, so if you happen to also need a definition in one of those other headers, you can include that other header only.