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

NAME

6       stdint.h - integer types
7

SYNOPSIS

9       #include <stdint.h>
10

DESCRIPTION

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

APPLICATION USAGE

405       None.
406

RATIONALE

408       The <stdint.h> header is a subset of the <inttypes.h> header more suit‐
409       able  for use in freestanding environments, which might not support the
410       formatted I/O functions. In some environments, if the formatted conver‐
411       sion  support  is  not  wanted,  using this header instead of the <int‐
412       types.h> header avoids defining such a large number of macros.
413
414       As a consequence of adding int8_t, the following are true:
415
416        * A byte is exactly 8 bits.
417
418        * {CHAR_BIT}  has  the  value  8,  {SCHAR_MAX}  has  the  value   127,
419          {SCHAR_MIN}  has  the  value  -127  or -128, and {UCHAR_MAX} has the
420          value 255.
421

FUTURE DIRECTIONS

423       typedef names beginning with int or uint and  ending  with  _t  may  be
424       added to the types defined in the <stdint.h> header. Macro names begin‐
425       ning with INT or UINT and ending with _MAX, _MIN, or _C may be added to
426       the macros defined in the <stdint.h> header.
427

SEE ALSO

429       <inttypes.h>, <signal.h>, <stddef.h>, <wchar.h>
430
432       Portions  of  this text are reprinted and reproduced in electronic form
433       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
434       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
435       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
436       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
437       event of any discrepancy between this version and the original IEEE and
438       The  Open Group Standard, the original IEEE and The Open Group Standard
439       is the referee document. The original Standard can be  obtained  online
440       at http://www.opengroup.org/unix/online.html .
441
442
443
444IEEE/The Open Group                  2003                       <stdint.h>(0P)
Impressum