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
|
.\" 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 intN_t 3type 2024-05-02 "Linux man-pages (unreleased)"
.SH NAME
intN_t, int8_t, int16_t, int32_t, int64_t,
uintN_t, uint8_t, uint16_t, uint32_t, uint64_t
\- fixed-width basic integer types
.SH LIBRARY
Standard C library
.RI ( libc )
.SH SYNOPSIS
.nf
.B #include <stdint.h>
.P
.BR typedef " /* ... */ " int8_t;
.BR typedef " /* ... */ " int16_t;
.BR typedef " /* ... */ " int32_t;
.BR typedef " /* ... */ " int64_t;
.P
.BR typedef " /* ... */ " uint8_t;
.BR typedef " /* ... */ " uint16_t;
.BR typedef " /* ... */ " uint32_t;
.BR typedef " /* ... */ " uint64_t;
.P
.B "#define INT8_WIDTH 8"
.B "#define INT16_WIDTH 16"
.B "#define INT32_WIDTH 32"
.B "#define INT64_WIDTH 64"
.P
.B "#define UINT8_WIDTH 8"
.B "#define UINT16_WIDTH 16"
.B "#define UINT32_WIDTH 32"
.B "#define UINT64_WIDTH 64"
.P
.BR "#define INT8_MAX " "/* 2**(INT8_WIDTH - 1) - 1 */"
.BR "#define INT16_MAX " "/* 2**(INT16_WIDTH - 1) - 1 */"
.BR "#define INT32_MAX " "/* 2**(INT32_WIDTH - 1) - 1 */"
.BR "#define INT64_MAX " "/* 2**(INT64_WIDTH - 1) - 1 */"
.P
.BR "#define INT8_MIN " "/* - 2**(INT8_WIDTH - 1) */"
.BR "#define INT16_MIN " "/* - 2**(INT16_WIDTH - 1) */"
.BR "#define INT32_MIN " "/* - 2**(INT32_WIDTH - 1) */"
.BR "#define INT64_MIN " "/* - 2**(INT64_WIDTH - 1) */"
.P
.BR "#define UINT8_MAX " "/* 2**INT8_WIDTH - 1 */"
.BR "#define UINT16_MAX " "/* 2**INT16_WIDTH - 1 */"
.BR "#define UINT32_MAX " "/* 2**INT32_WIDTH - 1 */"
.BR "#define UINT64_MAX " "/* 2**INT64_WIDTH - 1 */"
.P
.BI "#define INT8_C(" c ") " c " ## " "\fR/* ... */\fP"
.BI "#define INT16_C(" c ") " c " ## " "\fR/* ... */\fP"
.BI "#define INT32_C(" c ") " c " ## " "\fR/* ... */\fP"
.BI "#define INT64_C(" c ") " c " ## " "\fR/* ... */\fP"
.P
.BI "#define UINT8_C(" c ") " c " ## " "\fR/* ... */\fP"
.BI "#define UINT16_C(" c ") " c " ## " "\fR/* ... */\fP"
.BI "#define UINT32_C(" c ") " c " ## " "\fR/* ... */\fP"
.BI "#define UINT64_C(" c ") " c " ## " "\fR/* ... */\fP"
.fi
.SH DESCRIPTION
.IR int N _t
are
signed integer types
of a fixed width of exactly N bits,
.I N
being the value specified in its type name.
They are be capable of storing values in the range
.RB [ INT \fIN\fP _MIN ,
.BR INT \fIN\fP _MAX ],
substituting
.I N
by the appropriate number.
.P
.IR uint N _t
are
unsigned integer types
of a fixed width of exactly N bits,
N being the value specified in its type name.
They are capable of storing values in the range
.RB [ 0 ,
.BR UINT \fIN\fP _MAX ],
substituting
.I N
by the appropriate number.
.P
According to POSIX,
.RI [ u ] int8_t ,
.RI [ u ] int16_t ,
and
.RI [ u ] int32_t
are required;
.RI [ u ] int64_t
are only required in implementations that provide integer types with width 64;
and all other types of this form are optional.
.P
The macros
.RB [ U ] INT \fIN\fP _WIDTH
expand to the width in bits of these types
.RI ( N ).
.P
The macros
.RB [ U ] INT \fIN\fP _MAX
expand to the maximum value that these types can hold.
.P
The macros
.BI INT N _MIN
expand to the minimum value that these types can hold.
.P
The macros
.RB [ U ] INT \fIN\fP _C ()
expand their argument to an integer constant of type
.RI [ u ] int N _t .
.P
The length modifiers for the
.RI [ u ] int N _t
types for the
.BR printf (3)
family of functions
are expanded by macros of the forms
.BR PRId \fIN\fP,
.BR PRIi \fIN\fP,
.BR PRIu \fIN\fP,
and
.BI PRIx N
(defined in
.IR <inttypes.h> );
resulting for example in
.B %"PRId64"
or
.B %"PRIi64"
for printing
.I int64_t
values.
The length modifiers for the
.RI [ u ] int N _t
types for the
.BR scanf (3)
family of functions
are expanded by macros of the forms
.BR SCNd \fIN\fP,
.BR SCNi \fIN\fP,
.BR SCNu \fIN\fP,
and
.BI SCNx N,
(defined in
.IR <inttypes.h> );
resulting for example in
.B %"SCNu8"
or
.B %"SCNx8"
for scanning
.I uint8_t
values.
.SH STANDARDS
C11, POSIX.1-2008.
.SH HISTORY
C99, POSIX.1-2001.
.P
The
.RB [ U ] INT \fIN\fP _WIDTH
macros were added in C23.
.SH NOTES
The following header also provides these types:
.IR <inttypes.h> .
.I <arpa/inet.h>
also provides
.I uint16_t
and
.IR uint32_t .
.SH SEE ALSO
.BR intmax_t (3type),
.BR intptr_t (3type),
.BR printf (3)
|