summaryrefslogtreecommitdiffstats
path: root/man/man3type/size_t.3type
blob: 92efc81394ccac6a941c9ecf333af88bd153e77c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
.\" Copyright (c) 2020-2022 by Alejandro Colomar <alx@kernel.org>
.\" and Copyright (c) 2020 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.\"
.TH size_t 3type (date) "Linux man-pages (unreleased)"
.SH NAME
size_t, ssize_t \- count of bytes
.SH LIBRARY
Standard C library
.RI ( libc )
.SH SYNOPSIS
.nf
.B #include <stddef.h>
.P
.BR typedef " /* ... */  " size_t;
.P
.B #include <sys/types.h>
.P
.BR typedef " /* ... */  " ssize_t;
.fi
.SH DESCRIPTION
.TP
.I size_t
Used for a count of bytes.
It is the result of the
.IR sizeof ()
operator.
It is an unsigned integer type
capable of storing values in the range
.RB [ 0 ,
.BR SIZE_MAX ].
.TP
.I ssize_t
Used for a count of bytes or an error indication.
It is a signed integer type
capable of storing values at least in the range
.RB [ \-1 ,
.BR SSIZE_MAX ].
.SS Use with printf(3) and scanf(3)
.TP
.I size_t
The length modifier for
.I size_t
for the
.BR printf (3)
and the
.BR scanf (3)
families of functions is
.BR z ,
resulting commonly in
.B %zu
or
.B %zx
for printing
.I size_t
values.
.TP
.I ssize_t
glibc and most other implementations provide a length modifier for
.I ssize_t
for the
.BR printf (3)
and the
.BR scanf (3)
families of functions,
which is
.BR z ;
resulting commonly in
.B %zd
or
.B %zi
for printing
.I ssize_t
values.
Although
.B z
works for
.I ssize_t
on most implementations,
portable POSIX programs should avoid using it\[em]for example,
by converting the value to
.I intmax_t
and using its length modifier
.RB ( j ).
.SH STANDARDS
.TP
.I size_t
C11, POSIX.1-2008.
.TP
.I ssize_t
POSIX.1-2008.
.PD
.SH HISTORY
.TP
.I size_t
C89, POSIX.1-2001.
.TP
.I ssize_t
POSIX.1-2001.
.P
.IR <aio.h> ,
.IR <glob.h> ,
.IR <grp.h> ,
.IR <iconv.h> ,
.IR <mqueue.h> ,
.IR <pwd.h> ,
.IR <signal.h> ,
and
.I <sys/socket.h>
define
.I size_t
since POSIX.1-2008.
.P
.IR <aio.h> ,
.IR <mqueue.h> ,
and
.I <sys/socket.h>
define
.I ssize_t
since POSIX.1-2008.
.SH NOTES
.TP
.I size_t
The following headers also provide
.IR size_t :
.IR <aio.h> ,
.IR <glob.h> ,
.IR <grp.h> ,
.IR <iconv.h> ,
.IR <monetary.h> ,
.IR <mqueue.h> ,
.IR <ndbm.h> ,
.IR <pwd.h> ,
.IR <regex.h> ,
.IR <search.h> ,
.IR <signal.h> ,
.IR <stdio.h> ,
.IR <stdlib.h> ,
.IR <string.h> ,
.IR <strings.h> ,
.IR <sys/mman.h> ,
.IR <sys/msg.h> ,
.IR <sys/sem.h> ,
.IR <sys/shm.h> ,
.IR <sys/socket.h> ,
.IR <sys/types.h> ,
.IR <sys/uio.h> ,
.IR <time.h> ,
.IR <unistd.h> ,
.IR <wchar.h> ,
and
.IR <wordexp.h> .
.TP
.I ssize_t
The following headers also provide
.IR ssize_t :
.IR <aio.h> ,
.IR <monetary.h> ,
.IR <mqueue.h> ,
.IR <stdio.h> ,
.IR <sys/msg.h> ,
.IR <sys/socket.h> ,
.IR <sys/uio.h> ,
and
.IR <unistd.h> .
.SH SEE ALSO
.BR read (2),
.BR readlink (2),
.BR readv (2),
.BR recv (2),
.BR send (2),
.BR write (2),
.BR fread (3),
.BR fwrite (3),
.BR memcmp (3),
.BR memcpy (3),
.BR memset (3),
.BR offsetof (3),
.BR ptrdiff_t (3type)