inttypes.h(3)              POSIX Programmer's Manual             inttypes.h(3)



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

NNAAMMEE
       inttypes.h -- fixed size integer types

SSYYNNOOPPSSIISS
       #include <inttypes.h>

DDEESSCCRRIIPPTTIIOONN
       Some of the functionality described on this reference page extends the
       ISO C standard. Applications shall define the appropriate feature test
       macro (see the System Interfaces volume of POSIX.1-2017, _S_e_c_t_i_o_n _2_._2,
       _T_h_e _C_o_m_p_i_l_a_t_i_o_n _E_n_v_i_r_o_n_m_e_n_t) to enable the visibility of these symbols
       in this header.

       The _<_i_n_t_t_y_p_e_s_._h_> header shall include the _<_s_t_d_i_n_t_._h_> header.

       The _<_i_n_t_t_y_p_e_s_._h_> header shall define at least the following types:

       iimmaaxxddiivv__tt   Structure type that is the type of the value returned by
                   the _i_m_a_x_d_i_v() function.

       wwcchhaarr__tt     As described in _<_s_t_d_d_e_f_._h_>.

       The _<_i_n_t_t_y_p_e_s_._h_> header shall define the following macros. Each expands
       to a character string literal containing a conversion specifier,
       possibly modified by a length modifier, suitable for use within the
       _f_o_r_m_a_t argument of a formatted input/output function when converting
       the corresponding integer type. These macros have the general form of
       PRI (character string literals for the _f_p_r_i_n_t_f() and _f_w_p_r_i_n_t_f() family
       of functions) or SCN (character string literals for the _f_s_c_a_n_f() and
       _f_w_s_c_a_n_f() family of functions), followed by the conversion specifier,
       followed by a name corresponding to a similar type name in _<_s_t_d_i_n_t_._h_>.
       In these names, _N represents the width of the type as described in
       _<_s_t_d_i_n_t_._h_>.  For example, _P_R_I_d_F_A_S_T_3_2 can be used in a format string to
       print the value of an integer of type iinntt__ffaasstt3322__tt.

       The _f_p_r_i_n_t_f() macros for signed integers are:


              PRId_N        PRIdLEAST_N   PRIdFAST_N    PRIdMAX      PRIdPTR
              PRIi_N        PRIiLEAST_N   PRIiFAST_N    PRIiMAX      PRIiPTR

       The _f_p_r_i_n_t_f() macros for unsigned integers are:


              PRIo_N        PRIoLEAST_N   PRIoFAST_N    PRIoMAX      PRIoPTR
              PRIu_N        PRIuLEAST_N   PRIuFAST_N    PRIuMAX      PRIuPTR
              PRIx_N        PRIxLEAST_N   PRIxFAST_N    PRIxMAX      PRIxPTR
              PRIX_N        PRIXLEAST_N   PRIXFAST_N    PRIXMAX      PRIXPTR

       The _f_s_c_a_n_f() macros for signed integers are:


              SCNd_N        SCNdLEAST_N   SCNdFAST_N    SCNdMAX      SCNdPTR
              SCNi_N        SCNiLEAST_N   SCNiFAST_N    SCNiMAX      SCNiPTR

       The _f_s_c_a_n_f() macros for unsigned integers are:


              SCNo_N        SCNoLEAST_N   SCNoFAST_N    SCNoMAX      SCNoPTR
              SCNu_N        SCNuLEAST_N   SCNuFAST_N    SCNuMAX      SCNuPTR
              SCNx_N        SCNxLEAST_N   SCNxFAST_N    SCNxMAX      SCNxPTR

       For each type that the implementation provides in _<_s_t_d_i_n_t_._h_>, the
       corresponding _f_p_r_i_n_t_f() and _f_w_p_r_i_n_t_f() macros shall be defined and the
       corresponding _f_s_c_a_n_f() and _f_w_s_c_a_n_f() macros shall be defined unless the
       implementation does not have a suitable modifier for the type.

       The following shall be declared as functions and may also be defined as
       macros. Function prototypes shall be provided.


           intmax_t  imaxabs(intmax_t);
           imaxdiv_t imaxdiv(intmax_t, intmax_t);
           intmax_t  strtoimax(const char *restrict, char **restrict, int);
           uintmax_t strtoumax(const char *restrict, char **restrict, int);
           intmax_t  wcstoimax(const wchar_t *restrict, wchar_t **restrict, int);
           uintmax_t wcstoumax(const wchar_t *restrict, wchar_t **restrict, int);

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       #include <inttypes.h>
       #include <wchar.h>
       int main(void)
       {
           uintmax_t i = UINTMAX_MAX; // This type always exists.
           wprintf(L"The largest integer value is %020"
               PRIxMAX "\n", i);
           return 0;
       }

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The purpose of _<_i_n_t_t_y_p_e_s_._h_> is to provide a set of integer types whose
       definitions are consistent across machines and independent of operating
       systems and other implementation idiosyncrasies. It defines, through
       ttyyppeeddeeff, integer types of various sizes. Implementations are free to
       ttyyppeeddeeff them as ISO C standard integer types or extensions that they
       support. Consistent use of this header will greatly increase the
       portability of applications across platforms.

RRAATTIIOONNAALLEE
       The ISO/IEC 9899:1990 standard specified that the language should
       support four signed and unsigned integer data types--cchhaarr, sshhoorrtt, iinntt,
       and lloonngg--but placed very little requirement on their size other than
       that iinntt and sshhoorrtt be at least 16 bits and lloonngg be at least as long as
       iinntt and not smaller than 32 bits. For 16-bit systems, most
       implementations assigned 8, 16, 16, and 32 bits to cchhaarr, sshhoorrtt, iinntt,
       and lloonngg, respectively. For 32-bit systems, the common practice has
       been to assign 8, 16, 32, and 32 bits to these types. This difference
       in iinntt size can create some problems for users who migrate from one
       system to another which assigns different sizes to integer types,
       because the ISO C standard integer promotion rule can produce silent
       changes unexpectedly.  The need for defining an extended integer type
       increased with the introduction of 64-bit systems.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       Macro names beginning with PRI or SCN followed by any lowercase letter
       or ''XX'' may be added to the macros defined in the _<_i_n_t_t_y_p_e_s_._h_> header.

SSEEEE AALLSSOO
       <<ssttddddeeff..hh>>

       The System Interfaces volume of POSIX.1-2017, _S_e_c_t_i_o_n _2_._2, _T_h_e
       _C_o_m_p_i_l_a_t_i_o_n _E_n_v_i_r_o_n_m_e_n_t, _i_m_a_x_a_b_s(), _i_m_a_x_d_i_v(), _s_t_r_t_o_i_m_a_x(), _w_c_s_t_o_i_m_a_x()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                        inttypes.h(3)
