1stdint.h(0P)               POSIX Programmer's Manual              stdint.h(0P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       stdint.h — integer types
13

SYNOPSIS

15       #include <stdint.h>
16

DESCRIPTION

18       Some of the functionality described on this reference page extends  the
19       ISO C  standard. Applications shall define the appropriate feature test
20       macro (see the System Interfaces volume of POSIX.1‐2017,  Section  2.2,
21       The  Compilation Environment) to enable the visibility of these symbols
22       in this header.
23
24       The <stdint.h> header shall declare sets of integer types having speci‐
25       fied  widths,  and  shall define corresponding sets of macros. It shall
26       also define macros that specify limits of integer  types  corresponding
27       to types defined in other standard headers.
28
29       Note:     The  ``width''  of an integer type is the number of bits used
30                 to store its value in a pure binary system; the  actual  type
31                 may use more bits than that (for example, a 28-bit type could
32                 be stored in 32 bits of actual storage). An N-bit signed type
33                 has  values  in the range -2N-1 or 1-2N-1 to 2N-1-1, while an
34                 N-bit unsigned type has values in the range 0 to 2N-1.
35
36       Types are defined in the following categories:
37
38        *  Integer types having certain exact widths
39
40        *  Integer types having at least certain specified widths
41
42        *  Fastest integer types having at least certain specified widths
43
44        *  Integer types wide enough to hold pointers to objects
45
46        *  Integer types having greatest width
47
48       (Some of these types may denote the same type.)
49
50       Corresponding macros specify limits of the declared types and construct
51       suitable constants.
52
53       For  each  type  described herein that the implementation provides, the
54       <stdint.h> header shall declare that typedef name and define the  asso‐
55       ciated  macros.  Conversely,  for  each  type described herein that the
56       implementation does  not  provide,  the  <stdint.h>  header  shall  not
57       declare  that  typedef name, nor shall it define the associated macros.
58       An implementation shall provide those types described as required,  but
59       need not provide any of the others (described as optional).
60
61   Integer Types
62       When  typedef  names  differing  only in the absence or presence of the
63       initial u are defined,  they  shall  denote  corresponding  signed  and
64       unsigned  types as described in the ISO/IEC 9899:1999 standard, Section
65       6.2.5; an implementation providing one  of  these  corresponding  types
66       shall also provide the other.
67
68       In the following descriptions, the symbol N represents an unsigned dec‐
69       imal integer with no leading zeros (for example, 8 or 24, but not 04 or
70       048).
71
72        *  Exact-width integer types
73
74           The typedef name intN_t designates a signed integer type with width
75           N, no padding bits, and a  two's-complement  representation.  Thus,
76           int8_t  denotes  a  signed  integer  type with a width of exactly 8
77           bits.
78
79           The typedef name uintN_t designates an unsigned integer  type  with
80           width  N.   Thus,  uint24_t denotes an unsigned integer type with a
81           width of exactly 24 bits.
82
83           The following types are required:
84
85           int8_t
86           int16_t
87           int32_t
88           uint8_t
89           uint16_t
90           uint32_t
91
92           If an implementation provides integer types with width 64 that meet
93           these  requirements, then the following types are required: int64_t
94           uint64_t
95
96           In particular, this will be the case if any of  the  following  are
97           true:
98
99           --  The implementation supports the _POSIX_V7_ILP32_OFFBIG program‐
100               ming environment and the application  is  being  built  in  the
101               _POSIX_V7_ILP32_OFFBIG  programming  environment (see the Shell
102               and Utilities volume of POSIX.1‐2017, c99, Programming Environ‐
103               ments).
104
105           --  The  implementation  supports the _POSIX_V7_LP64_OFF64 program‐
106               ming environment and the application  is  being  built  in  the
107               _POSIX_V7_LP64_OFF64 programming environment.
108
109           --  The implementation supports the _POSIX_V7_LPBIG_OFFBIG program‐
110               ming environment and the application  is  being  built  in  the
111               _POSIX_V7_LPBIG_OFFBIG programming environment.
112
113           All other types of this form are optional.
114
115        *  Minimum-width integer types
116
117           The typedef name int_leastN_t designates a signed integer type with
118           a width of at least N, such that no signed integer type with lesser
119           size  has at least the specified width. Thus, int_least32_t denotes
120           a signed integer type with a width of at least 32 bits.
121
122           The typedef name uint_leastN_t designates an unsigned integer  type
123           with a width of at least N, such that no unsigned integer type with
124           lesser size has at least the specified width. Thus,  uint_least16_t
125           denotes an unsigned integer type with a width of at least 16 bits.
126
127           The   following  types  are  required:  int_least8_t  int_least16_t
128           int_least32_t    int_least64_t     uint_least8_t     uint_least16_t
129           uint_least32_t uint_least64_t
130
131           All other types of this form are optional.
132
133        *  Fastest minimum-width integer types
134
135           Each of the following types designates an integer type that is usu‐
136           ally fastest to operate with among all integer types that  have  at
137           least the specified width.
138
139           The  designated  type  is not guaranteed to be fastest for all pur‐
140           poses; if the implementation has no clear grounds for choosing  one
141           type over another, it will simply pick some integer type satisfying
142           the signedness and width requirements.
143
144           The typedef name int_fastN_t designates the fastest signed  integer
145           type  with  a  width  of at least N.  The typedef name uint_fastN_t
146           designates the fastest unsigned integer type with  a  width  of  at
147           least N.
148
149           The   following   types   are  required:  int_fast8_t  int_fast16_t
150           int_fast32_t int_fast64_t uint_fast8_t uint_fast16_t  uint_fast32_t
151           uint_fast64_t
152
153           All other types of this form are optional.
154
155        *  Integer types capable of holding object pointers
156
157           The  following type designates a signed integer type with the prop‐
158           erty that any valid pointer to void can be converted to this  type,
159           then  converted back to a pointer to void, and the result will com‐
160           pare equal to the original pointer: intptr_t
161
162           The following type designates an unsigned  integer  type  with  the
163           property  that  any  valid pointer to void can be converted to this
164           type, then converted back to a pointer to void, and the result will
165           compare equal to the original pointer: uintptr_t
166
167           On  XSI-conformant  systems,  the  intptr_t and uintptr_t types are
168           required; otherwise, they are optional.
169
170        *  Greatest-width integer types
171
172           The following type designates a signed integer type capable of rep‐
173           resenting any value of any signed integer type: intmax_t
174
175           The  following  type designates an unsigned integer type capable of
176           representing any value of any unsigned integer type: uintmax_t
177
178           These types are required.
179
180       Note:     Applications can test for optional types by using the  corre‐
181                 sponding  limit  macro from Limits of Specified-Width Integer
182                 Types.
183
184   Limits of Specified-Width Integer Types
185       The following macros specify the minimum  and  maximum  limits  of  the
186       types declared in the <stdint.h> header. Each macro name corresponds to
187       a similar type name in Integer Types.
188
189       Each instance of any defined macro shall  be  replaced  by  a  constant
190       expression  suitable  for use in #if preprocessing directives, and this
191       expression shall have the same type as would an expression that  is  an
192       object  of  the  corresponding  type converted according to the integer
193       promotions. Its implementation-defined  value  shall  be  equal  to  or
194       greater  in  magnitude  (absolute  value)  than the corresponding value
195       given below, with the same sign, except where stated to be exactly  the
196       given value.
197
198        *  Limits of exact-width integer types
199
200           --  Minimum values of exact-width signed integer types:
201
202               {INTN_MIN}      Exactly -(2^N-1)
203
204           --  Maximum values of exact-width signed integer types:
205
206               {INTN_MAX}      Exactly 2^N-1 -1
207
208           --  Maximum values of exact-width unsigned integer types:
209
210               {UINTN_MAX}     Exactly 2^N -1
211
212        *  Limits of minimum-width integer types
213
214           --  Minimum values of minimum-width signed integer types:
215
216               {INT_LEASTN_MIN}
217                               -(2^N-1 -1)
218
219           --  Maximum values of minimum-width signed integer types:
220
221               {INT_LEASTN_MAX}
222                               2^N-1 -1
223
224           --  Maximum values of minimum-width unsigned integer types:
225
226               {UINT_LEASTN_MAX}
227                               2^N -1
228
229        *  Limits of fastest minimum-width integer types
230
231           --  Minimum values of fastest minimum-width signed integer types:
232
233               {INT_FASTN_MIN} -(2^N-1 -1)
234
235           --  Maximum values of fastest minimum-width signed integer types:
236
237               {INT_FASTN_MAX} 2^N-1 -1
238
239           --  Maximum values of fastest minimum-width unsigned integer types:
240
241               {UINT_FASTN_MAX}
242                               2^N -1
243
244        *  Limits of integer types capable of holding object pointers
245
246           --  Minimum value of pointer-holding signed integer type:
247
248               {INTPTR_MIN}    -(2^15 -1)
249
250           --  Maximum value of pointer-holding signed integer type:
251
252               {INTPTR_MAX}    2^15 -1
253
254           --  Maximum value of pointer-holding unsigned integer type:
255
256               {UINTPTR_MAX}   2^16 -1
257
258        *  Limits of greatest-width integer types
259
260           --  Minimum value of greatest-width signed integer type:
261
262               {INTMAX_MIN}    -(2^63 -1)
263
264           --  Maximum value of greatest-width signed integer type:
265
266               {INTMAX_MAX}    2^63 -1
267
268           --  Maximum value of greatest-width unsigned integer type:
269
270               {UINTMAX_MAX}   2^64 -1
271
272   Limits of Other Integer Types
273       The  following macros specify the minimum and maximum limits of integer
274       types corresponding to types defined in other standard headers.
275
276       Each instance of these macros shall be replaced by a  constant  expres‐
277       sion suitable for use in #if preprocessing directives, and this expres‐
278       sion shall have the same type as would an expression that is an  object
279       of  the  corresponding  type  converted according to the integer promo‐
280       tions. Its implementation-defined value shall be equal to or greater in
281       magnitude  (absolute  value)  than the corresponding value given below,
282       with the same sign.
283
284        *  Limits of ptrdiff_t:
285
286           {PTRDIFF_MIN}   -65535
287
288           {PTRDIFF_MAX}   +65535
289
290        *  Limits of sig_atomic_t:
291
292           {SIG_ATOMIC_MIN}
293                           See below.
294
295           {SIG_ATOMIC_MAX}
296                           See below.
297
298        *  Limit of size_t:
299
300           {SIZE_MAX}      65535
301
302        *  Limits of wchar_t:
303
304           {WCHAR_MIN}     See below.
305
306           {WCHAR_MAX}     See below.
307
308        *  Limits of wint_t:
309
310           {WINT_MIN}      See below.
311
312           {WINT_MAX}      See below.
313
314       If sig_atomic_t (see the <signal.h> header)  is  defined  as  a  signed
315       integer  type,  the  value of {SIG_ATOMIC_MIN} shall be no greater than
316       -127 and the value of {SIG_ATOMIC_MAX} shall be no less than 127;  oth‐
317       erwise,  sig_atomic_t shall be defined as an unsigned integer type, and
318       the  value  of  {SIG_ATOMIC_MIN}  shall  be  0   and   the   value   of
319       {SIG_ATOMIC_MAX} shall be no less than 255.
320
321       If  wchar_t  (see the <stddef.h> header) is defined as a signed integer
322       type, the value of {WCHAR_MIN} shall be no greater than  -127  and  the
323       value  of  {WCHAR_MAX}  shall  be  no less than 127; otherwise, wchar_t
324       shall be defined  as  an  unsigned  integer  type,  and  the  value  of
325       {WCHAR_MIN}  shall  be  0 and the value of {WCHAR_MAX} shall be no less
326       than 255.
327
328       If wint_t (see the <wchar.h> header) is defined  as  a  signed  integer
329       type,  the  value of {WINT_MIN} shall be no greater than -32767 and the
330       value of {WINT_MAX} shall be no  less  than  32767;  otherwise,  wint_t
331       shall  be  defined  as  an  unsigned  integer  type,  and  the value of
332       {WINT_MIN} shall be 0 and the value of {WINT_MAX} shall be no less than
333       65535.
334
335   Macros for Integer Constant Expressions
336       The  following  macros  expand to integer constant expressions suitable
337       for initializing objects that have integer types corresponding to types
338       defined in the <stdint.h> header. Each macro name corresponds to a sim‐
339       ilar type name listed under Minimum-width integer types  and  Greatest-
340       width integer types.
341
342       Each  invocation of one of these macros shall expand to an integer con‐
343       stant expression suitable for use in #if preprocessing directives.  The
344       type  of the expression shall have the same type as would an expression
345       that is an object of the corresponding type converted according to  the
346       integer  promotions.  The  value of the expression shall be that of the
347       argument.
348
349       The argument in any instance of these macros  shall  be  an  unsuffixed
350       integer  constant  with a value that does not exceed the limits for the
351       corresponding type.
352
353        *  Macros for minimum-width integer constant expressions
354
355           The macro INTN_C(value) shall expand to an integer constant expres‐
356           sion   corresponding   to   the   type   int_leastN_t.   The  macro
357           UINTN_C(value) shall expand to an integer constant expression  cor‐
358           responding   to   the   type   uint_leastN_t.    For   example,  if
359           uint_least64_t is a name for the  type  unsigned  long  long,  then
360           UINT64_C(0x123) might expand to the integer constant 0x123ULL.
361
362        *  Macros for greatest-width integer constant expressions
363
364           The  following macro expands to an integer constant expression hav‐
365           ing the value specified by its argument and the type intmax_t: INT‐
366           MAX_C(value)
367
368           The  following macro expands to an integer constant expression hav‐
369           ing the value specified by its argument  and  the  type  uintmax_t:
370           UINTMAX_C(value)
371
372       The following sections are informative.
373

APPLICATION USAGE

375       None.
376

RATIONALE

378       The <stdint.h> header is a subset of the <inttypes.h> header more suit‐
379       able for use in freestanding environments, which might not support  the
380       formatted I/O functions. In some environments, if the formatted conver‐
381       sion support is not wanted, using this  header  instead  of  the  <int‐
382       types.h> header avoids defining such a large number of macros.
383
384       As a consequence of adding int8_t, the following are true:
385
386        *  A byte is exactly 8 bits.
387
388        *  {CHAR_BIT}  has  the  value  8,  {SCHAR_MAX}  has  the  value  127,
389           {SCHAR_MIN} has the value -128, and {UCHAR_MAX} has the value 255.
390
391       (The POSIX standard explicitly requires 8-bit char and two's-complement
392       arithmetic.)
393

FUTURE DIRECTIONS

395       typedef  names  beginning  with  int  or uint and ending with _t may be
396       added to the types defined in the <stdint.h> header. Macro names begin‐
397       ning with INT or UINT and ending with _MAX, _MIN, or _C may be added to
398       the macros defined in the <stdint.h> header.
399

SEE ALSO

401       <inttypes.h>, <signal.h>, <stddef.h>, <wchar.h>
402
403       The System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compila‐
404       tion Environment
405
407       Portions  of  this text are reprinted and reproduced in electronic form
408       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
409       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
410       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
411       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
412       event of any discrepancy between this version and the original IEEE and
413       The  Open Group Standard, the original IEEE and The Open Group Standard
414       is the referee document. The original Standard can be  obtained  online
415       at http://www.opengroup.org/unix/online.html .
416
417       Any  typographical  or  formatting  errors that appear in this page are
418       most likely to have been introduced during the conversion of the source
419       files  to  man page format. To report such errors, see https://www.ker
420       nel.org/doc/man-pages/reporting_bugs.html .
421
422
423
424IEEE/The Open Group                  2017                         stdint.h(0P)
Impressum