⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inttypes.h.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>&lt;inttypes.h&gt;</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="&lt;inttypes.h&gt;"></a> <a name="tag_13_20"></a><!-- &lt;inttypes.h&gt; --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_13_20_01"></a>NAME</h4><blockquote>inttypes.h - fixed size integer types</blockquote><h4><a name="tag_13_20_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><tt>#include &lt;inttypes.h&gt;</tt></p></blockquote><h4><a name="tag_13_20_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> Some of the functionality described on this reference page extends the ISO&nbsp;C standard. Applications shall definethe appropriate feature test macro (see the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../functions/xsh_chap02_02.html">Section 2.2, The Compilation Environment</a>) to enable the visibility of these symbols in thisheader. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>The <i>&lt;inttypes.h&gt;</i> header shall include the <a href="../basedefs/stdint.h.html"><i>&lt;stdint.h&gt;</i></a>header.</p><p>The <i>&lt;inttypes.h&gt;</i> header shall include a definition of at least the following type:</p><dl compact><dt><b>imaxdiv_t</b></dt><dd>Structure type that is the type of the value returned by the <a href="../functions/imaxdiv.html"><i>imaxdiv</i>()</a>function.</dd></dl><p>The following macros shall be defined. Each expands to a character string literal containing a conversion specifier, possiblymodified by a length modifier, suitable for use within the <i>format</i> argument of a formatted input/output function whenconverting the corresponding integer type. These macros have the general form of PRI (character string literals for the <a href="../functions/fprintf.html"><i>fprintf</i>()</a> and <a href="../functions/fwprintf.html"><i>fwprintf</i>()</a> family offunctions) or SCN (character string literals for the <a href="../functions/fscanf.html"><i>fscanf</i>()</a> and <a href="../functions/fwscanf.html"><i>fwscanf</i>()</a> family of functions), followed by the conversion specifier, followed by a namecorresponding to a similar type name in <a href="../basedefs/stdint.h.html"><i>&lt;stdint.h&gt;</i></a>. In these names, <i>N</i>represents the width of the type as described in <a href="../basedefs/stdint.h.html"><i>&lt;stdint.h&gt;</i></a>. For example,<i>PRIdFAST32</i> can be used in a format string to print the value of an integer of type <b>int_fast32_t</b>.</p><p>The <a href="../functions/fprintf.html"><i>fprintf</i>()</a> macros for signed integers are:</p><blockquote><table cellpadding="3"><tr valign="top"><td align="left"><p class="tent">PRId<i>N</i></p></td><td align="left"><p class="tent">PRIdLEAST<i>N</i></p></td><td align="left"><p class="tent">PRIdFAST<i>N</i></p></td><td align="left"><p class="tent">PRIdMAX</p></td><td align="left"><p class="tent">PRIdPTR</p></td></tr><tr valign="top"><td align="left"><p class="tent">PRIi<i>N</i></p></td><td align="left"><p class="tent">PRIiLEAST<i>N</i></p></td><td align="left"><p class="tent">PRIiFAST<i>N</i></p></td><td align="left"><p class="tent">PRIiMAX</p></td><td align="left"><p class="tent">PRIiPTR</p></td></tr></table></blockquote><p>The <a href="../functions/fprintf.html"><i>fprintf</i>()</a> macros for unsigned integers are:</p><blockquote><table cellpadding="3"><tr valign="top"><td align="left"><p class="tent">PRIo<i>N</i></p></td><td align="left"><p class="tent">PRIoLEAST<i>N</i></p></td><td align="left"><p class="tent">PRIoFAST<i>N</i></p></td><td align="left"><p class="tent">PRIoMAX</p></td><td align="left"><p class="tent">PRIoPTR</p></td></tr><tr valign="top"><td align="left"><p class="tent">PRIu<i>N</i></p></td><td align="left"><p class="tent">PRIuLEAST<i>N</i></p></td><td align="left"><p class="tent">PRIuFAST<i>N</i></p></td><td align="left"><p class="tent">PRIuMAX</p></td><td align="left"><p class="tent">PRIuPTR</p></td></tr><tr valign="top"><td align="left"><p class="tent">PRIx<i>N</i></p></td><td align="left"><p class="tent">PRIxLEAST<i>N</i></p></td><td align="left"><p class="tent">PRIxFAST<i>N</i></p></td><td align="left"><p class="tent">PRIxMAX</p></td><td align="left"><p class="tent">PRIxPTR</p></td></tr><tr valign="top"><td align="left"><p class="tent">PRIX<i>N</i></p></td><td align="left"><p class="tent">PRIXLEAST<i>N</i></p></td><td align="left"><p class="tent">PRIXFAST<i>N</i></p></td><td align="left"><p class="tent">PRIXMAX</p></td><td align="left"><p class="tent">PRIXPTR</p></td></tr></table></blockquote><p>The <a href="../functions/fscanf.html"><i>fscanf</i>()</a> macros for signed integers are:</p><blockquote><table cellpadding="3"><tr valign="top"><td align="left"><p class="tent">SCNd<i>N</i></p></td><td align="left"><p class="tent">SCNdLEAST<i>N</i></p></td><td align="left"><p class="tent">SCNdFAST<i>N</i></p></td><td align="left"><p class="tent">SCNdMAX</p></td><td align="left"><p class="tent">SCNdPTR</p></td></tr><tr valign="top"><td align="left"><p class="tent">SCNi<i>N</i></p></td><td align="left"><p class="tent">SCNiLEAST<i>N</i></p></td><td align="left"><p class="tent">SCNiFAST<i>N</i></p></td><td align="left"><p class="tent">SCNiMAX</p></td><td align="left"><p class="tent">SCNiPTR</p></td></tr></table></blockquote><p>The <a href="../functions/fscanf.html"><i>fscanf</i>()</a> macros for unsigned integers are:</p><blockquote><table cellpadding="3"><tr valign="top"><td align="left"><p class="tent">SCNo<i>N</i></p></td><td align="left"><p class="tent">SCNoLEAST<i>N</i></p></td><td align="left"><p class="tent">SCNoFAST<i>N</i></p></td><td align="left"><p class="tent">SCNoMAX</p></td><td align="left"><p class="tent">SCNoPTR</p></td></tr><tr valign="top"><td align="left"><p class="tent">SCNu<i>N</i></p></td><td align="left"><p class="tent">SCNuLEAST<i>N</i></p></td><td align="left"><p class="tent">SCNuFAST<i>N</i></p></td><td align="left"><p class="tent">SCNuMAX</p></td><td align="left"><p class="tent">SCNuPTR</p></td></tr><tr valign="top"><td align="left"><p class="tent">SCNx<i>N</i></p></td><td align="left"><p class="tent">SCNxLEAST<i>N</i></p></td><td align="left"><p class="tent">SCNxFAST<i>N</i></p></td><td align="left"><p class="tent">SCNxMAX</p></td><td align="left"><p class="tent">SCNxPTR</p></td></tr></table></blockquote><p>For each type that the implementation provides in <a href="../basedefs/stdint.h.html"><i>&lt;stdint.h&gt;</i></a>, thecorresponding <a href="../functions/fprintf.html"><i>fprintf</i>()</a> and <a href="../functions/fwprintf.html"><i>fwprintf</i>()</a> macros shall be defined and the corresponding <a href="../functions/fscanf.html"><i>fscanf</i>()</a> and <a href="../functions/fwscanf.html"><i>fwscanf</i>()</a> macros shall be definedunless the implementation does not have a suitable modifier for the type.</p><p>The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.</p><pre><tt>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);</tt></pre></blockquote><h4><a name="tag_13_20_04"></a>EXAMPLES</h4><blockquote><pre><tt>#include &lt;inttypes.h&gt;#include &lt;wchar.h&gt;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;}</tt></pre></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_13_20_05"></a>APPLICATION USAGE</h4><blockquote><p>The purpose of <i>&lt;inttypes.h&gt;</i> is to provide a set of integer types whose definitions are consistent across machinesand independent of operating systems and other implementation idiosyncrasies. It defines, via <b>typedef</b>, integer types ofvarious sizes. Implementations are free to <b>typedef</b> them as ISO&nbsp;C standard integer types or extensions that theysupport. Consistent use of this header will greatly increase the portability of applications across platforms.</p></blockquote><h4><a name="tag_13_20_06"></a>RATIONALE</h4><blockquote><p>The ISO/IEC&nbsp;9899:1990 standard specified that the language should support four signed and unsigned integer data types-<b>char</b>, <b>short</b>, <b>int</b>, and <b>long</b>- but placed very little requirement on their size other than that <b>int</b>and <b>short</b> be at least 16 bits and <b>long</b> be at least as long as <b>int</b> and not smaller than 32 bits. For 16-bitsystems, most implementations assigned 8, 16, 16, and 32 bits to <b>char</b>, <b>short</b>, <b>int</b>, and <b>long</b>,respectively. For 32-bit systems, the common practice has been to assign 8, 16, 32, and 32 bits to these types. This difference in<b>int</b> size can create some problems for users who migrate from one system to another which assigns different sizes to integertypes, because the ISO&nbsp;C standard integer promotion rule can produce silent changes unexpectedly. The need for defining anextended integer type increased with the introduction of 64-bit systems.</p></blockquote><h4><a name="tag_13_20_07"></a>FUTURE DIRECTIONS</h4><blockquote><p>Macro names beginning with PRI or SCN followed by any lowercase letter or <tt>'X'</tt> may be added to the macros defined in the<i>&lt;inttypes.h&gt;</i> header.</p></blockquote><h4><a name="tag_13_20_08"></a>SEE ALSO</h4><blockquote><p>The System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../functions/imaxdiv.html"><i>imaxdiv</i>()</a></p></blockquote><h4><a name="tag_13_20_09"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 5.</p></blockquote><h4><a name="tag_13_20_10"></a>Issue 6</h4><blockquote><p>The Open Group Base Resolution bwg97-006 is applied.</p><p>This reference page is updated to align with the ISO/IEC&nbsp;9899:1999 standard.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -