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