]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Standard Integer Types</title> | |
5 | <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> | |
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> | |
7 | <link rel="home" href="../index.html" title="Boost.Config"> | |
8 | <link rel="up" href="../index.html" title="Boost.Config"> | |
9 | <link rel="prev" href="build_config.html" title="Build Time Configuration"> | |
10 | <link rel="next" href="guidelines_for_boost_authors.html" title="Guidelines for Boost Authors"> | |
11 | </head> | |
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> | |
13 | <table cellpadding="2" width="100%"><tr> | |
14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> | |
15 | <td align="center"><a href="../../../../../index.html">Home</a></td> | |
16 | <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> | |
17 | <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> | |
18 | <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> | |
19 | <td align="center"><a href="../../../../../more/index.htm">More</a></td> | |
20 | </tr></table> | |
21 | <hr> | |
22 | <div class="spirit-nav"> | |
23 | <a accesskey="p" href="build_config.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="guidelines_for_boost_authors.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> | |
27 | <a name="boost_config.cstdint"></a><a class="link" href="cstdint.html" title="Standard Integer Types">Standard Integer Types</a> | |
28 | </h2></div></div></div> | |
29 | <div class="toc"><dl> | |
30 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.overview">Overview</a></span></dt> | |
31 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.rationale">Rationale</a></span></dt> | |
32 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.ce"><span class="emphasis"><em>Caveat emptor</em></span></a></span></dt> | |
33 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.exact_width_integer_types">Exact-width | |
34 | integer types</a></span></dt> | |
35 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.minimum_width_integer_types">Minimum-width | |
36 | integer types</a></span></dt> | |
37 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.fastest_minimum_width_integer_types">Fastest | |
38 | minimum-width integer types</a></span></dt> | |
39 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.greatest_width_integer_types">Greatest-width | |
40 | integer types</a></span></dt> | |
41 | <dt><span class="section"><a href="cstdint.html#boost_config.cstdint.integer_constant_macros">Integer | |
42 | Constant Macros</a></span></dt> | |
43 | </dl></div> | |
44 | <div class="section"> | |
45 | <div class="titlepage"><div><div><h3 class="title"> | |
46 | <a name="boost_config.cstdint.overview"></a><a class="link" href="cstdint.html#boost_config.cstdint.overview" title="Overview">Overview</a> | |
47 | </h3></div></div></div> | |
48 | <p> | |
49 | The header <code class="literal"><a href="../../../../../boost/cstdint.hpp" target="_top"><boost/cstdint.hpp></a></code> | |
50 | provides the typedef's useful for writing portable code that requires certain | |
51 | integer widths. All typedef's are in namespace boost. | |
52 | </p> | |
53 | <p> | |
54 | The specifications for these types are based on the ISO/IEC 9899:1999 C Language | |
55 | standard header <stdint.h>. The 64-bit types required by the C standard | |
56 | are <span class="emphasis"><em>not required</em></span> in the boost header, and may not be | |
57 | supplied for all platforms/compilers, because <code class="literal">long long</code> | |
58 | is not [yet] included in the C++ standard. | |
59 | </p> | |
60 | <p> | |
61 | See <a href="../../../test/cstdint_test.cpp" target="_top">cstdint_test.cpp</a> for | |
62 | a test program. | |
63 | </p> | |
64 | </div> | |
65 | <div class="section"> | |
66 | <div class="titlepage"><div><div><h3 class="title"> | |
67 | <a name="boost_config.cstdint.rationale"></a><a class="link" href="cstdint.html#boost_config.cstdint.rationale" title="Rationale">Rationale</a> | |
68 | </h3></div></div></div> | |
69 | <p> | |
70 | The organization of the Boost.Integer headers and classes is designed to | |
71 | take advantage of <stdint.h> types from the 1999 C standard without | |
72 | causing undefined behavior in terms of the 1998 C++ standard. The header | |
73 | <boost/cstdint.hpp> makes the standard integer types safely available | |
74 | in namespace <code class="literal">boost</code> without placing any names in namespace | |
75 | <code class="literal">std</code>. The intension is to complement rather than compete | |
76 | with the C++ Standard Library. Should some future C++ standard include <stdint.h> | |
77 | and <cstdint>, then <boost/cstdint.hpp> will continue to function, | |
78 | but will become redundant and may be safely deprecated. | |
79 | </p> | |
80 | <p> | |
81 | Because these are boost headers, their names conform to boost header naming | |
82 | conventions rather than C++ Standard Library header naming conventions. | |
83 | </p> | |
84 | </div> | |
85 | <div class="section"> | |
86 | <div class="titlepage"><div><div><h3 class="title"> | |
87 | <a name="boost_config.cstdint.ce"></a><a class="link" href="cstdint.html#boost_config.cstdint.ce" title="Caveat emptor"><span class="emphasis"><em>Caveat emptor</em></span></a> | |
88 | </h3></div></div></div> | |
89 | <p> | |
90 | As an implementation artifact, certain C <limits.h> macro names may | |
91 | possibly be visible to users of <boost/cstdint.hpp>. Don't use these | |
92 | macros; they are not part of any Boost-specified interface. Use <code class="literal">boost::integer_traits<></code> | |
93 | or <code class="literal">std::numeric_limits<></code> instead. | |
94 | </p> | |
95 | <p> | |
96 | As another implementation artifact, certain C <stdint.h> typedef names | |
97 | may possibly be visible in the global namespace to users of <boost/cstdint.hpp>. | |
98 | Don't use these names, they are not part of any Boost-specified interface. | |
99 | Use the respective names in namespace <code class="literal">boost</code> instead. | |
100 | </p> | |
101 | </div> | |
102 | <div class="section"> | |
103 | <div class="titlepage"><div><div><h3 class="title"> | |
104 | <a name="boost_config.cstdint.exact_width_integer_types"></a><a class="link" href="cstdint.html#boost_config.cstdint.exact_width_integer_types" title="Exact-width integer types">Exact-width | |
105 | integer types</a> | |
106 | </h3></div></div></div> | |
107 | <p> | |
108 | The typedef <code class="literal">int#_t</code>, with # replaced by the width, designates | |
109 | a signed integer type of exactly # bits; for example <code class="literal">int8_t</code> | |
110 | denotes an 8-bit signed integer type. Similarly, the typedef <code class="literal">uint#_t</code> | |
111 | designates an unsigned integer type of exactly # bits. | |
112 | </p> | |
113 | <p> | |
114 | These types are optional. However, if a platform supports integer types with | |
115 | widths of 8, 16, 32, 64, or any combination thereof, then <boost/cstdint.hpp> | |
116 | does provide the corresponding typedefs. | |
117 | </p> | |
118 | <p> | |
119 | The absence of int64_t and uint64_t is indicated by the macro <code class="computeroutput"><span class="identifier">BOOST_NO_INT64_T</span></code>. | |
120 | </p> | |
121 | </div> | |
122 | <div class="section"> | |
123 | <div class="titlepage"><div><div><h3 class="title"> | |
124 | <a name="boost_config.cstdint.minimum_width_integer_types"></a><a class="link" href="cstdint.html#boost_config.cstdint.minimum_width_integer_types" title="Minimum-width integer types">Minimum-width | |
125 | integer types</a> | |
126 | </h3></div></div></div> | |
127 | <p> | |
128 | The typedef <code class="literal">int_least#_t</code>, with # replaced by the width, | |
129 | designates a signed integer type with a width of at least # bits, such that | |
130 | no signed integer type with lesser size has at least the specified width. | |
131 | Thus, <code class="literal">int_least32_t</code> denotes the smallest signed integer | |
132 | type with a width of at least 32 bits. Similarly, the typedef name <code class="literal">uint_least#_t</code> | |
133 | designates an unsigned integer type with a width of at least # bits, such | |
134 | that no unsigned integer type with lesser size has at least the specified | |
135 | width. | |
136 | </p> | |
137 | <p> | |
138 | The following minimum-width integer types are provided for all platforms: | |
139 | </p> | |
140 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
141 | <li class="listitem"> | |
142 | <code class="literal">int_least8_t</code> | |
143 | </li> | |
144 | <li class="listitem"> | |
145 | <code class="literal">int_least16_t</code> | |
146 | </li> | |
147 | <li class="listitem"> | |
148 | <code class="literal">int_least32_t</code> | |
149 | </li> | |
150 | <li class="listitem"> | |
151 | <code class="literal">uint_least8_t</code> | |
152 | </li> | |
153 | <li class="listitem"> | |
154 | <code class="literal">uint_least16_t</code> | |
155 | </li> | |
156 | <li class="listitem"> | |
157 | <code class="literal">uint_least32_t</code> | |
158 | </li> | |
159 | </ul></div> | |
160 | <p> | |
161 | The following types are available only if, after including <boost/cstdint.hpp>, | |
162 | the macro BOOST_NO_INT64_T is not defined: | |
163 | </p> | |
164 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
165 | <li class="listitem"> | |
166 | <code class="literal">int_least64_t</code> | |
167 | </li> | |
168 | <li class="listitem"> | |
169 | <code class="literal">uint_least64_t</code> | |
170 | </li> | |
171 | </ul></div> | |
172 | <p> | |
173 | All other minimum-width integer types are optional. | |
174 | </p> | |
175 | </div> | |
176 | <div class="section"> | |
177 | <div class="titlepage"><div><div><h3 class="title"> | |
178 | <a name="boost_config.cstdint.fastest_minimum_width_integer_types"></a><a class="link" href="cstdint.html#boost_config.cstdint.fastest_minimum_width_integer_types" title="Fastest minimum-width integer types">Fastest | |
179 | minimum-width integer types</a> | |
180 | </h3></div></div></div> | |
181 | <p> | |
182 | The typedef <code class="literal">int_fast#_t</code>, with # replaced by the width, | |
183 | designates the fastest signed integer type with a width of at least # bits. | |
184 | Similarly, the typedef name <code class="literal">uint_fast#_t</code> designates the | |
185 | fastest unsigned integer type with a width of at least # bits. | |
186 | </p> | |
187 | <p> | |
188 | There is no guarantee that these types are fastest for all purposes. In any | |
189 | case, however, they satisfy the signedness and width requirements. | |
190 | </p> | |
191 | <p> | |
192 | The following fastest minimum-width integer types are provided for all platforms: | |
193 | </p> | |
194 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
195 | <li class="listitem"> | |
196 | <code class="literal">int_fast8_t</code> | |
197 | </li> | |
198 | <li class="listitem"> | |
199 | <code class="literal">int_fast16_t</code> | |
200 | </li> | |
201 | <li class="listitem"> | |
202 | <code class="literal">int_fast32_t</code> | |
203 | </li> | |
204 | <li class="listitem"> | |
205 | <code class="literal">uint_fast8_t</code> | |
206 | </li> | |
207 | <li class="listitem"> | |
208 | <code class="literal">uint_fast16_t</code> | |
209 | </li> | |
210 | <li class="listitem"> | |
211 | <code class="literal">uint_fast32_t</code> | |
212 | </li> | |
213 | </ul></div> | |
214 | <p> | |
215 | The following types are available only if, after including <boost/cstdint.hpp>, | |
216 | the macro BOOST_NO_INT64_T is not defined: | |
217 | </p> | |
218 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
219 | <li class="listitem"> | |
220 | <code class="literal">int_fast64_t</code> | |
221 | </li> | |
222 | <li class="listitem"> | |
223 | <code class="literal">uint_fast64_t</code> | |
224 | </li> | |
225 | </ul></div> | |
226 | <p> | |
227 | All other fastest minimum-width integer types are optional. | |
228 | </p> | |
229 | </div> | |
230 | <div class="section"> | |
231 | <div class="titlepage"><div><div><h3 class="title"> | |
232 | <a name="boost_config.cstdint.greatest_width_integer_types"></a><a class="link" href="cstdint.html#boost_config.cstdint.greatest_width_integer_types" title="Greatest-width integer types">Greatest-width | |
233 | integer types</a> | |
234 | </h3></div></div></div> | |
235 | <p> | |
236 | The typedef <code class="literal">intmax_t </code>designates a signed integer type | |
237 | capable of representing any value of any signed integer type. | |
238 | </p> | |
239 | <p> | |
240 | The typedef <code class="literal">uintmax_t</code> designates an unsigned integer type | |
241 | capable of representing any value of any unsigned integer type. | |
242 | </p> | |
243 | <p> | |
244 | These types are provided for all platforms. | |
245 | </p> | |
246 | </div> | |
247 | <div class="section"> | |
248 | <div class="titlepage"><div><div><h3 class="title"> | |
249 | <a name="boost_config.cstdint.integer_constant_macros"></a><a class="link" href="cstdint.html#boost_config.cstdint.integer_constant_macros" title="Integer Constant Macros">Integer | |
250 | Constant Macros</a> | |
251 | </h3></div></div></div> | |
252 | <p> | |
253 | The following macros are always defined after inclusion of this header, these | |
254 | allow integer constants of at least the specified width to be declared: INT8_C, | |
255 | UINT8_C, INT16_C, UINT16_C, INT32_C, UINT32_C, INTMAX_C, UINTMAX_C. | |
256 | </p> | |
257 | <p> | |
258 | The macros INT64_C and UINT64_C are also defined if the the macro BOOST_NO_INT64_T | |
259 | is not defined. | |
260 | </p> | |
261 | <p> | |
262 | The C99 macro __STDC_CONSTANT_MACROS is also defined as an artifact of the | |
263 | implementation. | |
264 | </p> | |
265 | <p> | |
266 | For example: | |
267 | </p> | |
268 | <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">cstdint</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> | |
269 | ||
270 | <span class="comment">// Here the constant 0x1FFFFFFFF has the correct suffix applied:</span> | |
271 | <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint64_t</span> <span class="identifier">c</span> <span class="special">=</span> <span class="identifier">INT64_C</span><span class="special">(</span><span class="number">0</span><span class="identifier">x1FFFFFFFF</span><span class="special">);</span> | |
272 | </pre> | |
273 | </div> | |
274 | </div> | |
275 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
276 | <td align="left"></td> | |
277 | <td align="right"><div class="copyright-footer">Copyright © 2001-2007 Beman Dawes, Vesa Karvonen, John | |
278 | Maddock<p> | |
279 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
280 | file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) | |
281 | </p> | |
282 | </div></td> | |
283 | </tr></table> | |
284 | <hr> | |
285 | <div class="spirit-nav"> | |
286 | <a accesskey="p" href="build_config.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="guidelines_for_boost_authors.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
287 | </div> | |
288 | </body> | |
289 | </html> |