README: Update links
[man-pages.git] / man3type / intN_t.3type
blobeefcb33cc31953714ba4ce69c31ec14f77aa5971
1 .\" Copyright (c) 2020-2022 by Alejandro Colomar <alx@kernel.org>
2 .\" and Copyright (c) 2020 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\"
7 .TH intN_t 3type (date) "Linux man-pages (unreleased)"
8 .SH NAME
9 intN_t, int8_t, int16_t, int32_t, int64_t,
10 uintN_t, uint8_t, uint16_t, uint32_t, uint64_t
11 \- fixed-width basic integer types
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc )
15 .SH SYNOPSIS
16 .nf
17 .B #include <stdint.h>
19 .BR typedef " /* ... */ " int8_t;
20 .BR typedef " /* ... */ " int16_t;
21 .BR typedef " /* ... */ " int32_t;
22 .BR typedef " /* ... */ " int64_t;
24 .BR typedef " /* ... */ " uint8_t;
25 .BR typedef " /* ... */ " uint16_t;
26 .BR typedef " /* ... */ " uint32_t;
27 .BR typedef " /* ... */ " uint64_t;
29 .B "#define INT8_WIDTH   8"
30 .B "#define INT16_WIDTH  16"
31 .B "#define INT32_WIDTH  32"
32 .B "#define INT64_WIDTH  64"
34 .B "#define UINT8_WIDTH  8"
35 .B "#define UINT16_WIDTH 16"
36 .B "#define UINT32_WIDTH 32"
37 .B "#define UINT64_WIDTH 64"
39 .BR "#define INT8_MAX     " "/*  2**(INT8_WIDTH - 1) - 1   */"
40 .BR "#define INT16_MAX    " "/*  2**(INT16_WIDTH - 1) - 1  */"
41 .BR "#define INT32_MAX    " "/*  2**(INT32_WIDTH - 1) - 1  */"
42 .BR "#define INT64_MAX    " "/*  2**(INT64_WIDTH - 1) - 1  */"
44 .BR "#define INT8_MIN     " "/*  - 2**(INT8_WIDTH - 1)     */"
45 .BR "#define INT16_MIN    " "/*  - 2**(INT16_WIDTH - 1)    */"
46 .BR "#define INT32_MIN    " "/*  - 2**(INT32_WIDTH - 1)    */"
47 .BR "#define INT64_MIN    " "/*  - 2**(INT64_WIDTH - 1)    */"
49 .BR "#define UINT8_MAX    " "/*  2**INT8_WIDTH - 1         */"
50 .BR "#define UINT16_MAX   " "/*  2**INT16_WIDTH - 1        */"
51 .BR "#define UINT32_MAX   " "/*  2**INT32_WIDTH - 1        */"
52 .BR "#define UINT64_MAX   " "/*  2**INT64_WIDTH - 1        */"
54 .BI "#define INT8_C(" c ")    " c " ## " "\fR/* ... */\fP"
55 .BI "#define INT16_C(" c ")   " c " ## " "\fR/* ... */\fP"
56 .BI "#define INT32_C(" c ")   " c " ## " "\fR/* ... */\fP"
57 .BI "#define INT64_C(" c ")   " c " ## " "\fR/* ... */\fP"
59 .BI "#define UINT8_C(" c ")   " c " ## " "\fR/* ... */\fP"
60 .BI "#define UINT16_C(" c ")  " c " ## " "\fR/* ... */\fP"
61 .BI "#define UINT32_C(" c ")  " c " ## " "\fR/* ... */\fP"
62 .BI "#define UINT64_C(" c ")  " c " ## " "\fR/* ... */\fP"
63 .fi
64 .SH DESCRIPTION
65 .IR int N _t
66 are
67 signed integer types
68 of a fixed width of exactly N bits,
69 .I N
70 being the value specified in its type name.
71 They are be capable of storing values in the range
72 .RB [ INT \fIN\fP _MIN ,
73 .BR INT \fIN\fP _MAX ],
74 substituting
75 .I N
76 by the appropriate number.
78 .IR uint N _t
79 are
80 unsigned integer types
81 of a fixed width of exactly N bits,
82 N being the value specified in its type name.
83 They are capable of storing values in the range
84 .RB [ 0 ,
85 .BR UINT \fIN\fP _MAX ],
86 substituting
87 .I N
88 by the appropriate number.
90 According to POSIX,
91 .RI [ u ] int8_t ,
92 .RI [ u ] int16_t ,
93 and
94 .RI [ u ] int32_t
95 are required;
96 .RI [ u ] int64_t
97 are only required in implementations that provide integer types with width 64;
98 and all other types of this form are optional.
100 The macros
101 .RB [ U ] INT \fIN\fP _WIDTH
102 expand to the width in bits of these types
103 .RI ( N ).
105 The macros
106 .RB [ U ] INT \fIN\fP _MAX
107 expand to the maximum value that these types can hold.
109 The macros
110 .BI INT N _MIN
111 expand to the minimum value that these types can hold.
113 The macros
114 .RB [ U ] INT \fIN\fP _C ()
115 expand their argument to an integer constant of type
116 .RI [ u ] int N _t .
118 The length modifiers for the
119 .RI [ u ] int N _t
120 types for the
121 .BR printf (3)
122 family of functions
123 are expanded by macros of the forms
124 .BR PRId \fIN\fP,
125 .BR PRIi \fIN\fP,
126 .BR PRIu \fIN\fP,
128 .BI PRIx N
129 (defined in
130 .IR <inttypes.h> );
131 resulting for example in
132 .B %"PRId64"
134 .B %"PRIi64"
135 for printing
136 .I int64_t
137 values.
138 The length modifiers for the
139 .RI [ u ] int N _t
140 types for the
141 .BR scanf (3)
142 family of functions
143 are expanded by macros of the forms
144 .BR SCNd \fIN\fP,
145 .BR SCNi \fIN\fP,
146 .BR SCNu \fIN\fP,
148 .BI SCNx N,
149 (defined in
150 .IR <inttypes.h> );
151 resulting for example in
152 .B %"SCNu8"
154 .B %"SCNx8"
155 for scanning
156 .I uint8_t
157 values.
158 .SH STANDARDS
159 C11, POSIX.1-2008.
160 .SH HISTORY
161 C99, POSIX.1-2001.
164 .RB [ U ] INT \fIN\fP _WIDTH
165 macros were added in C23.
166 .SH NOTES
167 The following header also provides these types:
168 .IR <inttypes.h> .
169 .I <arpa/inet.h>
170 also provides
171 .I uint16_t
173 .IR uint32_t .
174 .SH SEE ALSO
175 .BR intmax_t (3type),
176 .BR intptr_t (3type),
177 .BR printf (3)