Rewrite of C9_xxxx Subclause 7.4 _S_e_p_t_e_m_b_e_r _2_6_, _1_9_9_7 _D_o_c_u_m_e_n_t _N_o_. _W_G_1_4_/_N_7_6_1 _(_J_1_1_/_9_7_-_1_2_5_) _D_o_u_g_l_a_s _A. _G_w_y_n _U_S _A_r_m_y _R_e_s_e_a_r_c_h _L_a_b_o_r_a_t_o_r_y _A_d_e_l_p_h_i, _M_D _A_B_S_T_R_A_C_T _TTTT_hhhh_iiii_ssss _iiii_ssss _aaaa _pppp_rrrr_oooo_pppp_oooo_ssss_eeee_dddd _rrrr_eeee_pppp_llll_aaaa_cccc_eeee_mmmm_eeee_nnnn_tttt _ffff_oooo_rrrr _tttt_hhhh_eeee _cccc_uuuu_rrrr_rrrr_eeee_nnnn_tttt _CCCC_9999_x _((((_DDDD_rrrr_aaaa_ffff_tttt _1111_0000_)))) _ssss_uuuu_bbbb_cccc_llll_aaaa_uuuu_ssss_eeee _7777_...._4444_;;;; _iiii_tttt _ssss_uuuu_pppp_eeee_rrrr_ssss_eeee_dddd_eeee_ssss _DDDD_oooo_cccc_.... _NNNN_oooo_.... _WWWW_GGGG_1111_4444_////_NNNN_7777_3333_7777 _((((_JJJJ_1111_1111_////_9999_7777_----_1111_0000_0000_))))_,,,, _wwww_hhhh_iiii_cccc_hhhh _wwww_aaaa_ssss _dddd_iiii_ssss_tttt_rrrr_iiii_bbbb_uuuu_tttt_eeee_dddd _iiii_nnnn _tttt_hhhh_eeee _pppp_oooo_ssss_tttt_----_LLLL_oooo_nnnn_dddd_oooo_nnnn _mmmm_aaaa_iiii_llll_iiii_nnnn_gggg_.... _((((_AAAA_cccc_tttt_uuuu_aaaa_llll_llll_yyyy_,,,, _tttt_hhhh_aaaa_tttt _mmmm_aaaa_iiii_llll_iiii_nnnn_gggg _cccc_oooo_nnnn_tttt_aaaa_iiii_nnnn_eeee_dddd _tttt_hhhh_eeee _wwww_rrrr_oooo_nnnn_gggg _vvvv_eeee_rrrr_ssss_iiii_oooo_nnnn_;;;; _iiii_nnnn _tttt_hhhh_eeee _SSSS_CCCC_2222_2222_WWWW_GGGG_1111_4444 _mmmm_aaaa_iiii_llll_iiii_nnnn_gggg _llll_iiii_ssss_tttt_,,,, _IIII _aaaa_ssss_kkkk_eeee_dddd _tttt_hhhh_aaaa_tttt _iiii_tttt _bbbb_eeee _rrrr_eeee_pppp_llll_aaaa_cccc_eeee_dddd _bbbb_yyyy _tttt_hhhh_eeee _vvvv_eeee_rrrr_ssss_iiii_oooo_nnnn _iiii_nnnn _ffff_tttt_pppp_::::_::::_////_////_ffff_tttt_pppp_...._aaaa_rrrr_llll_...._mmmm_iiii_llll_////_aaaa_rrrr_cccc_hhhh_////_nnnn_7777_3333_7777_...._pppp_ssss.) _S_i_n_c_e _m_y _o_r_i_g_i_n_a_l _p_r_o_p_o_s_a_l, _I _h_a_v_e _r_e_c_e_i_v_e_d _m_u_c_h _u_s_e_f_u_l _f_e_e_d_b_a_c_k, _w_h_i_c_h _h_a_s _b_e_e_n _t_a_k_e_n _i_n_t_o _a_c_c_o_u_n_t. _I_n _t_h_e _c_o_u_r_s_e _o_f _t_h_i_s _w_o_r_k, _I _n_o_t_i_c_e_d _s_e_v_e_r_a_l _a_p_p_a_r_e_n_t _p_r_o_b_l_e_m_s _w_i_t_h _t_h_e _s_p_e_c_i_f_i_c_a_t_i_o_n. _I_n _f_i_x_i_n_g _t_h_e_s_e _p_r_o_b_l_e_m_s, _t_h_e_r_e _i_s _a _d_e_l_i_c_a_t_e _b_a_l_a_n_c_e _b_e_t_w_e_e_n _t_h_e _f_o_r_c_e _o_f _l_o_g_i_c_a_l _n_e_c_e_s_s_i_t_y _a_n_d _i_n_v_e_n_t_i_o_n. _V_e_r_t_i_c_a_l _b_a_r_s _i_n _t_h_e _m_a_r_g_i_n _i_n_d_i_c_a_t_e _i_n_n_o_v_a_t_i_o_n_s _t_h_a_t _I _h_a_v_e _i_d_e_n_t_i_f_i_e_d _a_s _p_o_t_e_n_t_i_a_l_l_y _c_o_n_t_r_o_v_e_r_s_i_a_l, _o_r _w_o_r_d_i_n_g _t_h_a_t _c_o_u_l_d _b_e _a_f_f_e_c_t_e_d _b_y _o_t_h_e_r _p_e_n_d_i_n_g _p_r_o_p_o_s_a_l_s; _I _h_a_v_e _i_s_o_l_a_t_e_d _t_h_e_s_e _s_o _t_h_a_t _i_f _a_n_y _o_f _t_h_e_m _i_s _m_o_d_i_f_i_e_d _o_r _r_e_j_e_c_t_e_d _b_y _t_h_e _C_o_m_m_i_t_t_e_e, _i_t _c_a_n _b_e _q_u_i_c_k_l_y _a_n_d _a_c_c_u_r_a_t_e_l_y _e_d_i_t_e_d _i_n _t_h_e _T_R_O_F_F _s_o_u_r_c_e _f_i_l_e _t_h_a_t _w_i_l_l _b_e _p_r_o_v_i_d_e_d _t_o _t_h_e _D_o_c_u_m_e_n_t _E_d_i_t_o_r _a_s _a ``_p_l_u_g-_i_n'' _r_e_p_l_a_c_e_m_e_n_t _f_o_r _t_h_e _o_l_d _s_u_b_c_l_a_u_s_e _7._4. 7.4 IIIInnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss <<<>>> The header declares sets of typedef names for integer types having specified widths and defines corresponding sets of macros. Typedef names are declared in the following categories: - integer types having certain exact widths; - integer types having at least certain specified widths; - fastest integer types having at least certain specified widths; Library 149 Document No. WG14/N761 (J11/97-125)Rewrite of September 26, 1997 - fastest integer types with unspecified width; - integer types large enough to hold pointers to objects; - integer types having greatest width. (Some of these typedef names may denote the same type.) Corresponding macros specify limits of the declared integer types, construct suitable character constants, and provide conversion specifiers for use with the formatted input/output functions. There are also four function-like macros for converting numeric character strings to greatest-width integers. For each typedef name described herein that can be declared | as a type existing in the implementation, shall | declare that typedef name, and it shall define the | associated macros. Conversely, for each typedef name | described herein that cannot be declared as a type existing in the implementation, shall not declare that typedef name, nor shall it define the associated macros. Throughout this subclause, the _w_i_d_t_h of an integer type is | defined as the number of significant bits, including sign if | any, in the representation of that type. | RRRReeeeccccoooommmmmmmmeeeennnnddddeeeedddd pppprrrraaaaccccttttiiiicccceeee Some of these typedef names may denote implementation- defined extended integer types. 7.4.1 TTTTyyyyppppeeeeddddeeeeffff nnnnaaaammmmeeeessss ffffoooorrrr iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss When typedef names differing only in the absence or presence of the initial u are declared, they shall denote corresponding signed and unsigned types as described in subclause 6.1.2.5. 7.4.1.1 EEEExxxxaaaacccctttt----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss Each of the following names designates an integer type that has exactly the specified width. These names have the general form of int_n_t _o_r _u_i_n_t_n_t _w_h_e_r_e _n _i_s _t_h_e _r_e_q_u_i_r_e_d _w_i_d_t_h. _F_o_r _e_x_a_m_p_l_e, _u_i_n_t_8__t _d_e_n_o_t_e_s _a_n _u_n_s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e _t_h_a_t _i_s _e_x_a_c_t_l_y _8 _b_i_t_s _w_i_d_e. _T_h_e _f_o_l_l_o_w_i_n_g _d_e_s_i_g_n_a_t_e _e_x_a_c_t-_w_i_d_t_h _s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _i_n_t_8__t _i_n_t_1_6__t _i_n_t_3_2__t _i_n_t_6_4__t 150 Library September 26, 1997Rewrite of Document No. WG14/N761 (J11/97-125) _T_h_e _f_o_l_l_o_w_i_n_g _d_e_s_i_g_n_a_t_e _e_x_a_c_t-_w_i_d_t_h _u_n_s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _u_i_n_t_8__t _u_i_n_t_1_6__t _u_i_n_t_3_2__t _u_i_n_t_6_4__t (_A_n_y _o_f _t_h_e_s_e _t_y_p_e_s _m_i_g_h_t _n_o_t _e_x_i_s_t.) _7._4._1._2 MMMMiiiinnnniiiimmmmuuuummmm----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss Each of the following names designates an integer type that has at least the specified width. These names have the general form of int_least_n__t _o_r _u_i_n_t__l_e_a_s_t_n__t _w_h_e_r_e _n _i_s _t_h_e _m_i_n_i_m_u_m _r_e_q_u_i_r_e_d _w_i_d_t_h. _F_o_r _e_x_a_m_p_l_e, _i_n_t__l_e_a_s_t_3_2__t _d_e_n_o_t_e_s _a _s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e _t_h_a_t _i_s _a_t _l_e_a_s_t _3_2 _b_i_t_s _w_i_d_e. _T_h_e _f_o_l_l_o_w_i_n_g _d_e_s_i_g_n_a_t_e _m_i_n_i_m_u_m-_w_i_d_t_h _s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _i_n_t__l_e_a_s_t_8__t _i_n_t__l_e_a_s_t_1_6__t _i_n_t__l_e_a_s_t_3_2__t _i_n_t__l_e_a_s_t_6_4__t _T_h_e _f_o_l_l_o_w_i_n_g _d_e_s_i_g_n_a_t_e _m_i_n_i_m_u_m-_w_i_d_t_h _u_n_s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _u_i_n_t__l_e_a_s_t_8__t _u_i_n_t__l_e_a_s_t_1_6__t _u_i_n_t__l_e_a_s_t_3_2__t _u_i_n_t__l_e_a_s_t_6_4__t (_T_h_e_s_e _t_y_p_e_s _m_u_s_t _e_x_i_s_t.) RRRReeeeccccoooommmmmmmmeeeennnnddddeeeedddd pppprrrraaaaccccttttiiiicccceeee _| Each of these names should denote one of the _s_m_a_l_l_e_s_t types _| satisfying the requirements. _| 7.4.1.3 FFFFaaaasssstttteeeesssstttt mmmmiiiinnnniiiimmmmuuuummmm----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss Each of the following names designates an integer type that is usually fastest to operate with among all integer types that have at least the specified width. These names have the general form of int_fast_n_t _o_r _u_i_n_t__f_a_s_t_n_t _w_h_e_r_e _n _i_s _t_h_e _m_i_n_i_m_u_m _r_e_q_u_i_r_e_d _w_i_d_t_h. _F_o_r _e_x_a_m_p_l_e, _i_n_t__f_a_s_t_1_6__t _d_e_n_o_t_e_s _t_h_e _f_a_s_t_e_s_t _s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e _t_h_a_t _i_s _a_t _l_e_a_s_t _1_6 _b_i_t_s _w_i_d_e. _T_h_e _f_o_l_l_o_w_i_n_g _d_e_s_i_g_n_a_t_e _f_a_s_t_e_s_t _m_i_n_i_m_u_m-_w_i_d_t_h _s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _i_n_t__f_a_s_t_8__t _i_n_t__f_a_s_t_1_6__t _i_n_t__f_a_s_t_3_2__t _i_n_t__f_a_s_t_6_4__t _T_h_e _f_o_l_l_o_w_i_n_g _d_e_s_i_g_n_a_t_e _f_a_s_t_e_s_t _m_i_n_i_m_u_m-_w_i_d_t_h _u_n_s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _u_i_n_t__f_a_s_t_8__t _u_i_n_t__f_a_s_t_1_6__t _u_i_n_t__f_a_s_t_3_2__t _u_i_n_t__f_a_s_t_6_4__t (_T_h_e_s_e _t_y_p_e_s _m_u_s_t _e_x_i_s_t.) _| Library 151 Document No. WG14/N761 (J11/97-125)Rewrite of September 26, 1997 RRRReeeeccccoooommmmmmmmeeeennnnddddeeeedddd pppprrrraaaaccccttttiiiicccceeee _| It is acknowledged that singling out one type as ``usually _| fastest'' can be problematic. If the implementation has no _| clear grounds for choosing one type over another, it may _| pick any integer type satisfying the signedness and width _| requirements. _| 7.4.1.4 FFFFaaaasssstttteeeesssstttt iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss The following name designates a signed integer type that is usually fastest among all signed integer types having widths of at least 16 bits: intfast_t It denotes the same type as int_fast16_t. | The following name designates an unsigned integer type that is usually fastest among all unsigned integer types having widths of at least 16 bits: uintfast_t It denotes the same type as uint_fast16_t. | (These types must exist.) | 7.4.1.5 IIIInnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss ccccaaaappppaaaabbbblllleeee ooooffff hhhhoooollllddddiiiinnnngggg oooobbbbjjjjeeeecccctttt ppppooooiiiinnnntttteeeerrrrssss The following name designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: intptr_t The following name designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: uintptr_t (Support for such conversions is a common extension; | however, either or both of these types might not exist.) | 7.4.1.6 GGGGrrrreeeeaaaatttteeeesssstttt----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss The following name designates a signed integer type capable of holding any value that can be represented by any signed integer type: intmax_t The following name designates an unsigned integer type capable of holding any value that can be represented by any unsigned integer type: 152 Library September 26, 1997Rewrite of Document No. WG14/N761 (J11/97-125) uintmax_t (These types must exist.) | 7.4.2 LLLLiiiimmmmiiiittttssss ooooffff iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss The following object-like macros specify the minimum and maximum limits of the integer types declared in . Each macro name corresponds to a similar typedef name in subclause 7.4.1. Each instance of any defined macro shall be replaced by a constant expression suitable for use in #if preprocessing directives, and this expression shall have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. Its implementation-defined value shall be equal to or greater in magnitude (absolute value) than the corresponding value given below, with the same sign. 7.4.2.1 LLLLiiiimmmmiiiittttssss ooooffff eeeexxxxaaaacccctttt----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss - minimum values of exact-width signed integer types INT8_MIN -127 INT16_MIN -32767 INT32_MIN -2147483647 INT64_MIN -9223372036854775807 (The value must be either -2n-1 or 1-2n-1.) - maximum values of exact-width signed integer types INT8_MAX +127 INT16_MAX +32767 INT32_MAX +2147483647 INT64_MAX +9223372036854775807 (The value must be 2n-1-1.) - maximum values of exact-width unsigned integer types UINT8_MAX 255 UINT16_MAX 65535 UINT32_MAX 4294967295 UINT64_MAX 18446744073709551615 (The value must be 2n-1.) 7.4.2.2 LLLLiiiimmmmiiiittttssss ooooffff mmmmiiiinnnniiiimmmmuuuummmm----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss - minimum values of minimum-width signed integer types INT_LEAST8_MIN -127 INT_LEAST16_MIN -32767 INT_LEAST32_MIN -2147483647 INT_LEAST64_MIN -9223372036854775807 Library 153 Document No. WG14/N761 (J11/97-125)Rewrite of September 26, 1997 - maximum values of minimum-width signed integer types INT_LEAST8_MAX +127 INT_LEAST16_MAX +32767 INT_LEAST32_MAX +2147483647 INT_LEAST64_MAX +9223372036854775807 - maximum values of minimum-width unsigned integer types UINT_LEAST8_MAX 255 UINT_LEAST16_MAX 65535 UINT_LEAST32_MAX 4294967295 UINT_LEAST64_MAX 18446744073709551615 7.4.2.3 LLLLiiiimmmmiiiittttssss ooooffff ffffaaaasssstttteeeesssstttt mmmmiiiinnnniiiimmmmuuuummmm----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss - minimum values of fastest minimum-width signed integer types INT_FAST8_MIN -127 INT_FAST16_MIN -32767 INT_FAST32_MIN -2147483647 INT_FAST64_MIN -9223372036854775807 - maximum values of fastest minimum-width signed integer types INT_FAST8_MAX +127 INT_FAST16_MAX +32767 INT_FAST32_MAX +2147483647 INT_FAST64_MAX +9223372036854775807 - maximum values of fastest minimum-width unsigned integer types UINT_FAST8_MAX 255 UINT_FAST16_MAX 65535 UINT_FAST32_MAX 4294967295 UINT_FAST64_MAX 18446744073709551615 7.4.2.4 LLLLiiiimmmmiiiittttssss ooooffff ffffaaaasssstttteeeesssstttt iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss - minimum value of fastest signed integer type INTFAST_MIN -32767 - maximum value of fastest signed integer type INTFAST_MAX +32767 - maximum value of fastest unsigned integer type UINTFAST_MAX 65535 154 Library September 26, 1997Rewrite of Document No. WG14/N761 (J11/97-125) 7.4.2.5 LLLLiiiimmmmiiiittttssss ooooffff iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss ccccaaaappppaaaabbbblllleeee ooooffff hhhhoooollllddddiiiinnnngggg oooobbbbjjjjeeeecccctttt ppppooooiiiinnnntttteeeerrrrssss - minimum value of pointer-holding signed integer type INTPTR_MIN -32767 - maximum value of pointer-holding signed integer type INTPTR_MAX +32767 - maximum value of pointer-holding unsigned integer type UINTPTR_MAX 65535 7.4.2.6 LLLLiiiimmmmiiiittttssss ooooffff ggggrrrreeeeaaaatttteeeesssstttt----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss - minimum value of greatest-width signed integer type INTMAX_MIN -9223372036854775807 - maximum value of greatest-width signed integer type INTMAX_MAX +9223372036854775807 - maximum value of greatest-width unsigned integer type UINTMAX_MAX 18446744073709551615 7.4.3 MMMMaaaaccccrrrroooossss ffffoooorrrr iiiinnnntttteeeeggggeeeerrrr ccccoooonnnnssssttttaaaannnnttttssss The following function-like macros expand to integer constants suitable for initializing objects that have integer types declared in . Each macro name corresponds to a similar typedef name in subclause 7.4.1.2 or 7.4.1.6. The argument in any instance of these macros shall be a decimal, octal, or hexadecimal constant (as defined in subclause 6.1.3.2) with a value that does not exceed the limits for the corresponding type. 7.4.3.1 MMMMaaaaccccrrrroooossss ffffoooorrrr mmmmiiiinnnniiiimmmmuuuummmm----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ccccoooonnnnssssttttaaaannnnttttssss Each of the following macros expands to an integer constant having the value specified by its argument and a type with at least the specified width. These names have the general form of INT_n_C _o_r _U_I_N_T_n_C _w_h_e_r_e _n _i_s _t_h_e _m_i_n_i_m_u_m _r_e_q_u_i_r_e_d _w_i_d_t_h. _F_o_r _e_x_a_m_p_l_e, _U_I_N_T_6_4__C(_0_x_1_2_3) _m_i_g_h_t _e_x_p_a_n_d _t_o _t_h_e _i_n_t_e_g_e_r _c_o_n_s_t_a_n_t _0_x_1_2_3_U_L_L. _T_h_e _f_o_l_l_o_w_i_n_g _e_x_p_a_n_d _t_o _i_n_t_e_g_e_r _c_o_n_s_t_a_n_t_s _t_h_a_t _h_a_v_e _s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _I_N_T_8__C(_v_a_l_u_e) _I_N_T_1_6__C(_v_a_l_u_e) _I_N_T_3_2__C(_v_a_l_u_e) _I_N_T_6_4__C(_v_a_l_u_e) Library 155 Document No. WG14/N761 (J11/97-125)Rewrite of September 26, 1997 _T_h_e _f_o_l_l_o_w_i_n_g _e_x_p_a_n_d _t_o _i_n_t_e_g_e_r _c_o_n_s_t_a_n_t_s _t_h_a_t _h_a_v_e _u_n_s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e_s: _U_I_N_T_8__C(_v_a_l_u_e) _U_I_N_T_1_6__C(_v_a_l_u_e) _U_I_N_T_3_2__C(_v_a_l_u_e) _U_I_N_T_6_4__C(_v_a_l_u_e) _7._4._3._2 MMMMaaaaccccrrrroooossss ffffoooorrrr ggggrrrreeeeaaaatttteeeesssstttt----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ccccoooonnnnssssttttaaaannnnttttssss The following macro expands to an integer constant having the value specified by its argument and a signed integer type having width at least as great as any other signed integer type: INTMAX_C(_v_a_l_u_e) _T_h_e _f_o_l_l_o_w_i_n_g _m_a_c_r_o _e_x_p_a_n_d_s _t_o _a_n _i_n_t_e_g_e_r _c_o_n_s_t_a_n_t _h_a_v_i_n_g _t_h_e _v_a_l_u_e _s_p_e_c_i_f_i_e_d _b_y _i_t_s _a_r_g_u_m_e_n_t _a_n_d _a_n _u_n_s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e _h_a_v_i_n_g _w_i_d_t_h _a_t _l_e_a_s_t _a_s _g_r_e_a_t _a_s _a_n_y _o_t_h_e_r _u_n_s_i_g_n_e_d _i_n_t_e_g_e_r _t_y_p_e: _U_I_N_T_M_A_X__C(_v_a_l_u_e) _7._4._4 MMMMaaaaccccrrrroooossss ffffoooorrrr ffffoooorrrrmmmmaaaatttt ssssppppeeeecccciiiiffffiiiieeeerrrrssss Each of the following object-like macros expands to a string literal containing a conversion specifier, possibly modified by a prefix such as h, _l, or ll, _s_u_i_t_a_b_l_e _f_o_r _u_s_e _w_i_t_h_i_n _t_h_e _f_o_r_m_a_t _a_r_g_u_m_e_n_t _o_f _a _f_o_r_m_a_t_t_e_d _i_n_p_u_t/_o_u_t_p_u_t _f_u_n_c_t_i_o_n _w_h_e_n _c_o_n_v_e_r_t_i_n_g _t_h_e _c_o_r_r_e_s_p_o_n_d_i_n_g _i_n_t_e_g_e_r _t_y_p_e. _T_h_e_s_e _n_a_m_e_s _h_a_v_e _t_h_e _g_e_n_e_r_a_l _f_o_r_m _o_f _P_R_I (character string literals for the fprintf _f_a_m_i_l_y), _S_C_N (character string literals for the fscanf _f_a_m_i_l_y),_1_2_2 _W_P_R_I (wide string literals for the _| fwprintf _f_a_m_i_l_y), _o_r _W_S_C_N (wide string literals for the _| fwscanf _f_a_m_i_l_y), _f_o_l_l_o_w_e_d _b_y _t_h_e _c_o_n_v_e_r_s_i_o_n _s_p_e_c_i_f_i_e_r, _f_o_l_l_o_w_e_d _b_y _a _n_a_m_e _c_o_r_r_e_s_p_o_n_d_i_n_g _t_o _a _s_i_m_i_l_a_r _t_y_p_e_d_e_f _n_a_m_e _i_n _s_u_b_c_l_a_u_s_e _7._4._1. _F_o_r _e_x_a_m_p_l_e, _P_R_I_d_F_A_S_T_3_2 can be used in a format string to print an integer of type int_fast32_t. _T_h_e _f_p_r_i_n_t_f macros for signed integers are: PRId8 PRId16 PRId32 PRId64 PRIdLEAST8 PRIdLEAST16 PRIdLEAST32 PRIdLEAST64 PRIdFAST8 PRIdFAST16 PRIdFAST32 PRIdFAST64 PRIdFAST PRIdMAX PRIdPTR PRIi8 PRIi16 PRIi32 PRIi64 __________ 122. Separate macros are given for fprintf and fscanf functions because, typically, different format specifiers are required for fprintf and fscanf even when the type is the same. 156 Library September 26, 1997Rewrite of Document No. WG14/N761 (J11/97-125) PRIiLEAST8 PRIiLEAST16 PRIiLEAST32 PRIiLEAST64 PRIiFAST8 PRIiFAST16 PRIiFAST32 PRIiFAST64 PRIiFAST PRIiMAX PRIiPTR _T_h_e _f_p_r_i_n_t_f macros for unsigned integers are: PRIo8 PRIo16 PRIo32 PRIo64 PRIoLEAST8 PRIoLEAST16 PRIoLEAST32 PRIoLEAST64 PRIoFAST8 PRIoFAST16 PRIoFAST32 PRIoFAST64 PRIoFAST PRIoMAX PRIoPTR PRIu8 PRIu16 PRIu32 PRIu64 PRIuLEAST8 PRIuLEAST16 PRIuLEAST32 PRIuLEAST64 PRIuFAST8 PRIuFAST16 PRIuFAST32 PRIuFAST64 PRIuFAST PRIuMAX PRIuPTR PRIx8 PRIx16 PRIx32 PRIx64 PRIxLEAST8 PRIxLEAST16 PRIxLEAST32 PRIxLEAST64 PRIxFAST8 PRIxFAST16 PRIxFAST32 PRIxFAST64 PRIxFAST PRIxMAX PRIxPTR PRIX8 PRIX16 PRIX32 PRIX64 PRIXLEAST8 PRIXLEAST16 PRIXLEAST32 PRIXLEAST64 PRIXFAST8 PRIXFAST16 PRIXFAST32 PRIXFAST64 PRIXFAST PRIXMAX PRIXPTR _T_h_e _f_s_c_a_n_f macros for signed integers are: SCNd8 SCNd16 SCNd32 SCNd64 SCNdLEAST8 SCNdLEAST16 SCNdLEAST32 SCNdLEAST64 | SCNdFAST8 SCNdFAST16 SCNdFAST32 SCNdFAST64 | SCNdFAST SCNdMAX SCNdPTR SCNi8 SCNi16 SCNi32 SCNi64 SCNiLEAST8 SCNiLEAST16 SCNiLEAST32 SCNiLEAST64 | SCNiFAST8 SCNiFAST16 SCNiFAST32 SCNiFAST64 | SCNiFAST SCNiMAX SCNiPTR _T_h_e _f_s_c_a_n_f macros for unsigned integers are: SCNo8 SCNo16 SCNo32 SCNo64 SCNoLEAST8 SCNoLEAST16 SCNoLEAST32 SCNoLEAST64 | SCNoFAST8 SCNoFAST16 SCNoFAST32 SCNoFAST64 | SCNoFAST SCNoMAX SCNoPTR SCNu8 SCNu16 SCNu32 SCNu64 SCNuLEAST8 SCNuLEAST16 SCNuLEAST32 SCNuLEAST64 | SCNuFAST8 SCNuFAST16 SCNuFAST32 SCNuFAST64 | SCNuFAST SCNuMAX SCNuPTR SCNx8 SCNx16 SCNx32 SCNx64 SCNxLEAST8 SCNxLEAST16 SCNxLEAST32 SCNxLEAST64 | SCNxFAST8 SCNxFAST16 SCNxFAST32 SCNxFAST64 | SCNxFAST SCNxMAX SCNxPTR Library 157 Document No. WG14/N761 (J11/97-125)Rewrite of September 26, 1997 _T_h_e _f_w_p_r_i_n_t_f macros for signed integers are: _| WPRId8 WPRId16 WPRId32 WPRId64 _| WPRIdLEAST8 WPRIdLEAST16 WPRIdLEAST32 WPRIdLEAST64 _| WPRIdFAST8 WPRIdFAST16 WPRIdFAST32 WPRIdFAST64 _| WPRIdFAST WPRIdMAX WPRIdPTR _| WPRIi8 WPRIi16 WPRIi32 WPRIi64 _| WPRIiLEAST8 WPRIiLEAST16 WPRIiLEAST32 WPRIiLEAST64 _| WPRIiFAST8 WPRIiFAST16 WPRIiFAST32 WPRIiFAST64 _| WPRIiFAST WPRIiMAX WPRIiPTR _| _T_h_e _f_w_p_r_i_n_t_f macros for unsigned integers are: _| WPRIo8 WPRIo16 WPRIo32 WPRIo64 _| WPRIoLEAST8 WPRIoLEAST16 WPRIoLEAST32 WPRIoLEAST64 _| WPRIoFAST8 WPRIoFAST16 WPRIoFAST32 WPRIoFAST64 _| WPRIoFAST WPRIoMAX WPRIoPTR _| WPRIu8 WPRIu16 WPRIu32 WPRIu64 _| WPRIuLEAST8 WPRIuLEAST16 WPRIuLEAST32 WPRIuLEAST64 _| WPRIuFAST8 WPRIuFAST16 WPRIuFAST32 WPRIuFAST64 _| WPRIuFAST WPRIuMAX WPRIuPTR _| WPRIx8 WPRIx16 WPRIx32 WPRIx64 _| WPRIxLEAST8 WPRIxLEAST16 WPRIxLEAST32 WPRIxLEAST64 _| WPRIxFAST8 WPRIxFAST16 WPRIxFAST32 WPRIxFAST64 _| WPRIxFAST WPRIxMAX WPRIxPTR _| WPRIX8 WPRIX16 WPRIX32 WPRIX64 _| WPRIXLEAST8 WPRIXLEAST16 WPRIXLEAST32 WPRIXLEAST64 _| WPRIXFAST8 WPRIXFAST16 WPRIXFAST32 WPRIXFAST64 _| WPRIXFAST WPRIXMAX WPRIXPTR _| _T_h_e _f_w_s_c_a_n_f macros for signed integers are: _| WSCNd8 WSCNd16 WSCNd32 WSCNd64 _| WSCNdLEAST8 WSCNdLEAST16 WSCNdLEAST32 WSCNdLEAST64 _| WSCNdFAST8 WSCNdFAST16 WSCNdFAST32 WSCNdFAST64 _| WSCNdFAST WSCNdMAX WSCNdPTR _| WSCNi8 WSCNi16 WSCNi32 WSCNi64 _| WSCNiLEAST8 WSCNiLEAST16 WSCNiLEAST32 WSCNiLEAST64 _| WSCNiFAST8 WSCNiFAST16 WSCNiFAST32 WSCNiFAST64 _| WSCNiFAST WSCNiMAX WSCNiPTR _| _T_h_e _f_w_s_c_a_n_f macros for unsigned integers are: _| WSCNo8 WSCNo16 WSCNo32 WSCNo64 _| WSCNoLEAST8 WSCNoLEAST16 WSCNoLEAST32 WSCNoLEAST64 _| WSCNoFAST8 WSCNoFAST16 WSCNoFAST32 WSCNoFAST64 _| WSCNoFAST WSCNoMAX WSCNoPTR _| WSCNu8 WSCNu16 WSCNu32 WSCNu64 _| WSCNuLEAST8 WSCNuLEAST16 WSCNuLEAST32 WSCNuLEAST64 _| 158 Library September 26, 1997Rewrite of Document No. WG14/N761 (J11/97-125) WSCNuFAST8 WSCNuFAST16 WSCNuFAST32 WSCNuFAST64 _| WSCNuFAST WSCNuMAX WSCNuPTR _| WSCNx8 WSCNx16 WSCNx32 WSCNx64 _| WSCNxLEAST8 WSCNxLEAST16 WSCNxLEAST32 WSCNxLEAST64 _| WSCNxFAST8 WSCNxFAST16 WSCNxFAST32 WSCNxFAST64 _| WSCNxFAST WSCNxMAX WSCNxPTR _| _B_e_c_a_u_s_e _t_h_e _d_e_f_a_u_l_t _a_r_g_u_m_e_n_t _p_r_o_m_o_t_i_o_n_s _d_o _n_o_t _a_f_f_e_c_t _| _p_o_i_n_t_e_r _p_a_r_a_m_e_t_e_r_s, _t_h_e_r_e _m_i_g_h_t _n_o_t _e_x_i_s_t _s_u_i_t_a_b_l_e _f_s_c_a_n_f _| (or fwscanf) _f_o_r_m_a_t _s_p_e_c_i_f_i_e_r_s _f_o_r _s_o_m_e _o_f _t_h_e _d_e_c_l_a_r_e_d _| _t_y_p_e_s, _p_a_r_t_i_c_u_l_a_r_l_y _t_h_o_s_e _w_i_t_h _t_y_p_e_d_e_f _n_a_m_e_s _c_o_n_t_a_i_n_i_n_g _8. _| Consequently, as a special exception to the requirement that _| the implementation define all macros associated with a _| declared type, in such a case the problematic fscanf (_o_r _| _f_w_s_c_a_n_f) macros may be left undefined. _| EEEExxxxaaaammmmpppplllleeee #include #include int main(void) { uintmax_t i = UINTMAX_MAX; // this type always exists| printf("The largest integer value is %020" PRIxMAX "\n", i); return 0; } 7.4.5 CCCCoooonnnnvvvveeeerrrrssssiiiioooonnnn mmmmaaaaccccrrrroooossss111122223333 ffffoooorrrr ggggrrrreeeeaaaatttteeeesssstttt----wwwwiiiiddddtttthhhh iiiinnnntttteeeeggggeeeerrrr ttttyyyyppppeeeessss 7.4.5.1 TTTThhhheeee ssssttttrrrrttttooooiiiimmmmaaaaxxxx macro SSSSyyyynnnnooooppppssssiiiissss #include intmax_t strtoimax(const char * restrict nptr, char ** restrict endptr, int base); __________ 123. strtoimax, strtoumax, wcstoimax, and wcstoumax are | specified as macros rather than functions, to allow them | to be implemented as synonyms for functions named in | subclauses 7.13.1 and 7.18.4.1. | Library 159 Document No. WG14/N761 (J11/97-125)Rewrite of September 26, 1997 DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn The strtoimax macro is equivalent to strtol, except that the initial portion of the string is converted to intmax_t representation. RRRReeeettttuuuurrrrnnnnssss The strtoimax macro returns the converted value, if any. If no conversion could be performed zero is returned. If the correct value is outside the range of representable values, INTMAX_MAX or INTMAX_MIN is returned (according to the sign of the value), and the value of the macro ERANGE is stored in errno. 7.4.5.2 TTTThhhheeee ssssttttrrrrttttoooouuuummmmaaaaxxxx macro SSSSyyyynnnnooooppppssssiiiissss #include uintmax_t strtoumax(const char * restrict nptr, char ** restrict endptr, int base); DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn The strtoumax macro is equivalent to strtoul, except that the initial portion of the string is converted to uintmax_t representation. RRRReeeettttuuuurrrrnnnnssss The strtoumax macro returns the converted value, if any. If no conversion could be performed zero is returned. If the correct value is outside the range of representable values, UINTMAX_MAX is returned, and the value of the macro ERANGE is stored in errno. 7.4.5.3 TTTThhhheeee wwwwccccssssttttooooiiiimmmmaaaaxxxx macro | SSSSyyyynnnnooooppppssssiiiissss | #include | intmax_t wcstoimax(const wchar_t * restrict nptr, | wchar_t ** restrict endptr, int base);| DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn | The wcstoimax macro is equivalent to wcstol, except that the | initial portion of the wide string is converted to intmax_t | representation. | 160 Library September 26, 1997Rewrite of Document No. WG14/N761 (J11/97-125) RRRReeeettttuuuurrrrnnnnssss | The wcstoimax macro returns the converted value, if any. If | no conversion could be performed zero is returned. If the | correct value is outside the range of representable values, | INTMAX_MAX or INTMAX_MIN is returned (according to the sign | of the value), and the value of the macro ERANGE is stored | in errno. | 7.4.5.4 TTTThhhheeee wwwwccccssssttttoooouuuummmmaaaaxxxx macro | SSSSyyyynnnnooooppppssssiiiissss | #include | uintmax_t wcstoumax(const wchar_t * restrict nptr, | wchar_t ** restrict endptr, int base);| DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn | The wcstoumax macro is equivalent to wcstoul, except that | the initial portion of the wide string is converted to | uintmax_t representation. | RRRReeeettttuuuurrrrnnnnssss | The wcstoumax macro returns the converted value, if any. If | no conversion could be performed zero is returned. If the | correct value is outside the range of representable values, | UINTMAX_MAX is returned, and the value of the macro ERANGE | is stored in errno. | Library 161