1inttypes.h(0P)             POSIX Programmer's Manual            inttypes.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       inttypes.h — fixed size integer types
13

SYNOPSIS

15       #include <inttypes.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 <inttypes.h> header shall include the <stdint.h> header.
25
26       The <inttypes.h> header shall define at least the following types:
27
28       imaxdiv_t   Structure type that is the type of the  value  returned  by
29                   the imaxdiv() function.
30
31       wchar_t     As described in <stddef.h>.
32
33       The <inttypes.h> header shall define the following macros. Each expands
34       to a character string literal containing a conversion specifier, possi‐
35       bly  modified  by a length modifier, suitable for use within the format
36       argument of a formatted input/output function when converting the  cor‐
37       responding  integer  type.  These  macros  have the general form of PRI
38       (character string literals for the fprintf() and fwprintf()  family  of
39       functions)  or SCN (character string literals for the fscanf() and fws‐
40       canf() family of functions), followed by the conversion specifier, fol‐
41       lowed by a name corresponding to a similar type name in <stdint.h>.  In
42       these names, N represents  the  width  of  the  type  as  described  in
43       <stdint.h>.   For example, PRIdFAST32 can be used in a format string to
44       print the value of an integer of type int_fast32_t.
45
46       The fprintf() macros for signed integers are:
47
48
49              PRIdN        PRIdLEASTN   PRIdFASTN    PRIdMAX      PRIdPTR
50              PRIiN        PRIiLEASTN   PRIiFASTN    PRIiMAX      PRIiPTR
51
52       The fprintf() macros for unsigned integers are:
53
54
55              PRIoN        PRIoLEASTN   PRIoFASTN    PRIoMAX      PRIoPTR
56              PRIuN        PRIuLEASTN   PRIuFASTN    PRIuMAX      PRIuPTR
57              PRIxN        PRIxLEASTN   PRIxFASTN    PRIxMAX      PRIxPTR
58              PRIXN        PRIXLEASTN   PRIXFASTN    PRIXMAX      PRIXPTR
59
60       The fscanf() macros for signed integers are:
61
62
63              SCNdN        SCNdLEASTN   SCNdFASTN    SCNdMAX      SCNdPTR
64              SCNiN        SCNiLEASTN   SCNiFASTN    SCNiMAX      SCNiPTR
65
66       The fscanf() macros for unsigned integers are:
67
68
69              SCNoN        SCNoLEASTN   SCNoFASTN    SCNoMAX      SCNoPTR
70              SCNuN        SCNuLEASTN   SCNuFASTN    SCNuMAX      SCNuPTR
71              SCNxN        SCNxLEASTN   SCNxFASTN    SCNxMAX      SCNxPTR
72
73       For each type that the implementation provides in <stdint.h>, the  cor‐
74       responding  fprintf()  and  fwprintf()  macros shall be defined and the
75       corresponding fscanf() and fwscanf() macros shall be defined unless the
76       implementation does not have a suitable modifier for the type.
77
78       The following shall be declared as functions and may also be defined as
79       macros. Function prototypes shall be provided.
80
81
82           intmax_t  imaxabs(intmax_t);
83           imaxdiv_t imaxdiv(intmax_t, intmax_t);
84           intmax_t  strtoimax(const char *restrict, char **restrict, int);
85           uintmax_t strtoumax(const char *restrict, char **restrict, int);
86           intmax_t  wcstoimax(const wchar_t *restrict, wchar_t **restrict, int);
87           uintmax_t wcstoumax(const wchar_t *restrict, wchar_t **restrict, int);
88
89       The following sections are informative.
90

EXAMPLES

92       #include <inttypes.h>
93       #include <wchar.h>
94       int main(void)
95       {
96           uintmax_t i = UINTMAX_MAX; // This type always exists.
97           wprintf(L"The largest integer value is %020"
98               PRIxMAX "\n", i);
99           return 0;
100       }
101

APPLICATION USAGE

103       The purpose of <inttypes.h> is to provide a set of integer types  whose
104       definitions are consistent across machines and independent of operating
105       systems and other implementation idiosyncrasies.  It  defines,  through
106       typedef,  integer  types  of various sizes. Implementations are free to
107       typedef them as ISO C standard integer types or  extensions  that  they
108       support. Consistent use of this header will greatly increase the porta‐
109       bility of applications across platforms.
110

RATIONALE

112       The ISO/IEC 9899:1990 standard specified that the language should  sup‐
113       port  four signed and unsigned integer data types—char, short, int, and
114       long—but placed very little requirement on their size other  than  that
115       int  and  short be at least 16 bits and long be at least as long as int
116       and not smaller than 32 bits. For 16-bit systems, most  implementations
117       assigned  8, 16, 16, and 32 bits to char, short, int, and long, respec‐
118       tively. For 32-bit systems, the common practice has been to  assign  8,
119       16,  32,  and  32  bits to these types. This difference in int size can
120       create some problems for users who migrate from one system  to  another
121       which assigns different sizes to integer types, because the ISO C stan‐
122       dard integer promotion rule can produce  silent  changes  unexpectedly.
123       The  need  for  defining  an  extended  integer type increased with the
124       introduction of 64-bit systems.
125

FUTURE DIRECTIONS

127       Macro names beginning with PRI or SCN followed by any lowercase  letter
128       or 'X' may be added to the macros defined in the <inttypes.h> header.
129

SEE ALSO

131       <stddef.h>
132
133       The System Interfaces volume of POSIX.1‐2017, Section 2.2, The Compila‐
134       tion Environment, imaxabs(), imaxdiv(), strtoimax(), wcstoimax()
135
137       Portions of this text are reprinted and reproduced in  electronic  form
138       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
139       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
140       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
141       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
142       event of any discrepancy between this version and the original IEEE and
143       The Open Group Standard, the original IEEE and The Open Group  Standard
144       is  the  referee document. The original Standard can be obtained online
145       at http://www.opengroup.org/unix/online.html .
146
147       Any typographical or formatting errors that appear  in  this  page  are
148       most likely to have been introduced during the conversion of the source
149       files to man page format. To report such errors,  see  https://www.ker
150       nel.org/doc/man-pages/reporting_bugs.html .
151
152
153
154IEEE/The Open Group                  2017                       inttypes.h(0P)
Impressum