📄 stdint.h.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><stdint.h></title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="<stdint.h>"></a> <a name="tag_13_48"></a><!-- <stdint.h> --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_13_48_01"></a>NAME</h4><blockquote>stdint.h - integer types</blockquote><h4><a name="tag_13_48_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><tt>#include <stdint.h></tt></p></blockquote><h4><a name="tag_13_48_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 C standard. Applications shall definethe appropriate feature test macro (see the System Interfaces volume of IEEE Std 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><stdint.h></i> header shall declare sets of integer types having specified widths, and shall define correspondingsets of macros. It shall also define macros that specify limits of integer types corresponding to types defined in other standardheaders. <basefont size="2"></p><dl><dt><b>Note:</b></dt><dd>The "width" of an integer type is the number of bits used to store its value in a pure binary system; the actual type may usemore bits than that (for example, a 28-bit type could be stored in 32 bits of actual storage). An <i>N</i>-bit signed type hasvalues in the range -2<small><sup><i>N</i>-1</sup></small> or 1-2<small><sup><i>N</i>-1</sup></small> to2<small><sup><i>N</i>-1</sup></small>-1, while an <i>N</i>-bit unsigned type has values in the range 0 to2<small><sup><i>N</i></sup></small>-1.</dd></dl><basefont size="3"> <p>Types are defined in the following categories:</p><ul><li><p>Integer types having certain exact widths</p></li><li><p>Integer types having at least certain specified widths</p></li><li><p>Fastest integer types having at least certain specified widths</p></li><li><p>Integer types wide enough to hold pointers to objects</p></li><li><p>Integer types having greatest width</p></li></ul><p>(Some of these types may denote the same type.)</p><p>Corresponding macros specify limits of the declared types and construct suitable constants.</p><p>For each type described herein that the implementation provides, the <i><stdint.h></i> header shall declare that<b>typedef</b> name and define the associated macros. Conversely, for each type described herein that the implementation does notprovide, the <i><stdint.h></i> header shall not declare that <b>typedef</b> name, nor shall it define the associated macros.An implementation shall provide those types described as required, but need not provide any of the others (described asoptional).</p><h5><a name="tag_13_48_03_01"></a>Integer Types</h5><p>When <b>typedef</b> names differing only in the absence or presence of the initial <i>u</i> are defined, they shall denotecorresponding signed and unsigned types as described in the ISO/IEC 9899:1999 standard, Section 6.2.5; an implementationproviding one of these corresponding types shall also provide the other.</p><p>In the following descriptions, the symbol <i>N</i> represents an unsigned decimal integer with no leading zeros (for example, 8or 24, but not 04 or 048).</p><ul><li><p>Exact-width integer types</p><p>The <b>typedef</b> name <b>int</b> <i>N</i> <b>_t</b> designates a signed integer type with width <i>N</i>, no padding bits, anda two's-complement representation. Thus, <b>int8_t</b> denotes a signed integer type with a width of exactly 8 bits.</p><p>The <b>typedef</b> name <b>uint</b> <i>N</i> <b>_t</b> designates an unsigned integer type with width <i>N</i>. Thus,<b>uint24_t</b> denotes an unsigned integer type with a width of exactly 24 bits.</p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Thefollowing types are required:</p><p><br><b>int8_t</b><br><b>int16_t</b><br><b>int32_t</b><br><b>uint8_t</b><br><b>uint16_t</b><br><b>uint32_t</b><img src="../images/opt-end.gif" alt="[Option End]" border="0"><br></p><p>If an implementation provides integer types with width 64 that meet these requirements, then the following types are required:<b>int64_t</b> <b>uint64_t</b></p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Inparticular, this will be the case if any of the following are true:</p><ul><li><p>The implementation supports the _POSIX_V6_ILP32_OFFBIG programming environment and the application is being built in the_POSIX_V6_ILP32_OFFBIG programming environment (see the Shell and Utilities volume of IEEE Std 1003.1-2001, <a href="../utilities/c99.html"><i>c99</i></a>, Programming Environments).</p></li><li><p>The implementation supports the _POSIX_V6_LP64_OFF64 programming environment and the application is being built in the_POSIX_V6_LP64_OFF64 programming environment.</p></li><li><p>The implementation supports the _POSIX_V6_LPBIG_OFFBIG programming environment and the application is being built in the_POSIX_V6_LPBIG_OFFBIG programming environment. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li></ul><p>All other types of this form are optional.</p></li><li><p>Minimum-width integer types</p><p>The <b>typedef</b> name <b>int_least</b> <i>N</i> <b>_t</b> designates a signed integer type with a width of at least <i>N</i>,such that no signed integer type with lesser size has at least the specified width. Thus, <b>int_least32_t</b> denotes a signedinteger type with a width of at least 32 bits.</p><p>The <b>typedef</b> name <b>uint_least</b> <i>N</i> <b>_t</b> designates an unsigned integer type with a width of at least<i>N</i>, such that no unsigned integer type with lesser size has at least the specified width. Thus, <b>uint_least16_t</b> denotesan unsigned integer type with a width of at least 16 bits.</p><p>The following types are required: <b>int_least8_t</b> <b>int_least16_t</b> <b>int_least32_t</b> <b>int_least64_t</b><b>uint_least8_t</b> <b>uint_least16_t</b> <b>uint_least32_t</b> <b>uint_least64_t</b></p><p>All other types of this form are optional.</p></li><li><p>Fastest minimum-width integer types</p><p>Each of the following types designates an integer type that is usually fastest to operate with among all integer types that haveat least the specified width.</p><p>The designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear grounds for choosingone type over another, it will simply pick some integer type satisfying the signedness and width requirements.</p><p>The <b>typedef</b> name <b>int_fast</b> <i>N</i> <b>_t</b> designates the fastest signed integer type with a width of at least<i>N</i>. The <b>typedef</b> name <b>uint_fast</b> <i>N</i> <b>_t</b> designates the fastest unsigned integer type with a width ofat least <i>N</i>.</p><p>The following types are required: <b>int_fast8_t</b> <b>int_fast16_t</b> <b>int_fast32_t</b> <b>int_fast64_t</b><b>uint_fast8_t</b> <b>uint_fast16_t</b> <b>uint_fast32_t</b> <b>uint_fast64_t</b></p><p>All other types of this form are optional.</p></li><li><p>Integer types capable of holding object pointers</p><p>The following type designates a signed integer type with the property that any valid pointer to <b>void</b> can be converted tothis type, then converted back to a pointer to <b>void</b>, and the result will compare equal to the original pointer:<b>intptr_t</b></p><p>The following type designates an unsigned integer type with the property that any valid pointer to <b>void</b> can be convertedto this type, then converted back to a pointer to <b>void</b>, and the result will compare equal to the original pointer:<b>uintptr_t</b></p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">On XSI-conformant systems, the <b>intptr_t</b> and <b>uintptr_t</b> types are required; <img src="../images/opt-end.gif" alt="[Option End]" border="0"> otherwise, they are optional.</p></li><li><p>Greatest-width integer types</p><p>The following type designates a signed integer type capable of representing any value of any signed integer type:<b>intmax_t</b></p><p>The following type designates an unsigned integer type capable of representing any value of any unsigned integer type:<b>uintmax_t</b></p><p>These types are required.</p></li></ul><basefont size="2"> <dl><dt><b>Note:</b></dt><dd>Applications can test for optional types by using the corresponding limit macro from <a href="#tag_13_48_03_02">Limits ofSpecified-Width Integer Types</a> .</dd></dl><basefont size="3"> <h5><a name="tag_13_48_03_02"></a>Limits of Specified-Width Integer Types</h5><p>The following macros specify the minimum and maximum limits of the types declared in the <i><stdint.h></i> header. Eachmacro name corresponds to a similar type name in <a href="#tag_13_48_03_01">Integer Types</a> .</p><p>Each instance of any defined macro shall be replaced by a constant expression suitable for use in <b>#if</b> preprocessingdirectives, and this expression shall have the same type as would an expression that is an object of the corresponding typeconverted according to the integer promotions. Its implementation-defined value shall be equal to or greater in magnitude (absolutevalue) than the corresponding value given below, with the same sign, except where stated to be exactly the given value.</p><ul><li><p>Limits of exact-width integer types</p><ul><li><p>Minimum values of exact-width signed integer types:</p><dl compact><dt>{INT<i>N</i>_MIN}</dt><dd>Exactly -(2 <small><sup>N-1</sup></small>)</dd></dl></li><li><p>Maximum values of exact-width signed integer types:</p><dl compact><dt>{INT<i>N</i>_MAX}</dt><dd>Exactly 2<small><sup>N-1</sup></small> -1</dd></dl></li><li><p>Maximum values of exact-width unsigned integer types:</p><dl compact><dt>{UINT<i>N</i>_MAX}</dt><dd>Exactly 2 <small><sup>N</sup></small> -1</dd></dl></li></ul></li><li><p>Limits of minimum-width integer types</p><ul><li><p>Minimum values of minimum-width signed integer types:</p><dl compact><dt>{INT_LEAST<i>N</i>_MIN}</dt><dd>-(2 <small><sup> N-1</sup></small> -1)</dd></dl></li><li><p>Maximum values of minimum-width signed integer types:</p><dl compact><dt>{INT_LEAST<i>N</i>_MAX}</dt><dd>2 <small><sup> N-1</sup></small> -1</dd></dl></li><li><p>Maximum values of minimum-width unsigned integer types:</p><dl compact><dt>{UINT_LEAST<i>N</i>_MAX}</dt><dd>2 <small><sup> N</sup></small> -1</dd></dl></li></ul></li><li>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -