• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[/
2    Boost.Config
3
4    Copyright (c) 2001 Beman Dawes
5    Copyright (c) 2001 Vesa Karvonen
6    Copyright (c) 2001 John Maddock
7
8    Distributed under the Boost Software License, Version 1.0.
9    (See accompanying file LICENSE_1_0.txt or copy at
10    http://www.boost.org/LICENSE_1_0.txt)
11]
12
13[section:cstdint Standard Integer Types]
14
15[section Overview]
16
17The header [^[@../../../../boost/cstdint.hpp <boost/cstdint.hpp>]] provides the typedef's useful
18for writing portable code that requires certain integer widths. All typedef's are in namespace boost.
19
20The specifications for these types are based on the ISO/IEC 9899:1999 C Language standard header <stdint.h>.
21The 64-bit types required by the C standard are ['not required] in the boost header,
22and may not be supplied for all platforms/compilers, because [^long long] is not [yet] included in the C++ standard.
23
24See [@../../test/cstdint_test.cpp cstdint_test.cpp] for a test program.
25
26[endsect]
27
28[section:rationale Rationale]
29
30The organization of the Boost.Integer headers and classes is designed to take advantage of <stdint.h> types from the
311999 C standard without causing undefined behavior in terms of the 1998 C++ standard.
32The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace [^boost]
33without placing any names in namespace [^std]. The intension is to complement rather than compete
34with the C++ Standard Library. Should some future C++ standard include <stdint.h> and <cstdint>,
35then <boost/cstdint.hpp> will continue to function, but will become redundant and may be safely deprecated.
36
37Because these are boost headers, their names conform to boost header naming conventions rather than
38C++ Standard Library header naming conventions.
39
40[endsect]
41
42[section:ce ['Caveat emptor]]
43
44As an implementation artifact, certain C <limits.h> macro names may possibly be
45visible to users of <boost/cstdint.hpp>. Don't use these macros; they are not part of
46any Boost-specified interface. Use [^boost::integer_traits<>] or [^std::numeric_limits<>] instead.
47
48As another implementation artifact, certain C <stdint.h> typedef names may possibly be visible
49in the global namespace to users of <boost/cstdint.hpp>. Don't use these names, they are not part of
50any Boost-specified interface. Use the respective names in namespace [^boost] instead.
51
52[endsect]
53
54[section Exact-width integer types]
55
56The typedef [^int#_t], with # replaced by the width, designates a signed integer type of exactly # bits;
57for example [^int8_t] denotes an 8-bit signed integer type. Similarly, the typedef [^uint#_t] designates an unsigned
58integer type of exactly # bits.
59
60These types are optional. However, if a platform supports integer types with widths of
618, 16, 32, 64, or any combination thereof, then <boost/cstdint.hpp> does provide the
62corresponding typedefs.
63
64The absence of int64_t and uint64_t is indicated by the macro `BOOST_NO_INT64_T`.
65
66[endsect]
67
68[section Minimum-width integer types]
69
70The typedef [^int_least#_t], with # replaced by the width, designates a signed integer type with a width
71of at least # bits, such that no signed integer type with lesser size has at least the specified width.
72Thus, [^int_least32_t] denotes the smallest signed integer type with a width of at least 32 bits.
73Similarly, the typedef name [^uint_least#_t] designates an unsigned integer type with a width of at least # bits,
74such that no unsigned integer type with lesser size has at least the specified width.
75
76The following minimum-width integer types are provided for all platforms:
77
78* [^int_least8_t]
79* [^int_least16_t]
80* [^int_least32_t]
81* [^uint_least8_t]
82* [^uint_least16_t]
83* [^uint_least32_t]
84
85The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
86
87* [^int_least64_t]
88* [^uint_least64_t]
89
90
91All other minimum-width integer types are optional.
92
93[endsect]
94
95[section Fastest minimum-width integer types]
96
97The typedef [^int_fast#_t], with # replaced by the width, designates the fastest signed integer type
98with a width of at least # bits. Similarly, the typedef name [^uint_fast#_t] designates the fastest
99unsigned integer type with a width of at least # bits.
100
101There is no guarantee that these types are fastest for all purposes. In any case, however, they satisfy
102the signedness and width requirements.
103
104The following fastest minimum-width integer types are provided for all platforms:
105
106* [^int_fast8_t]
107* [^int_fast16_t]
108* [^int_fast32_t]
109* [^uint_fast8_t]
110* [^uint_fast16_t]
111* [^uint_fast32_t]
112
113The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
114
115* [^int_fast64_t]
116* [^uint_fast64_t]
117
118All other fastest minimum-width integer types are optional.
119
120[endsect]
121
122[section Greatest-width integer types]
123
124The typedef [^intmax_t ]designates a signed integer type capable of representing any value of any signed integer type.
125
126The typedef [^uintmax_t] designates an unsigned integer type capable of representing any value of any unsigned integer type.
127
128These types are provided for all platforms.
129
130[endsect]
131
132[section Integer Constant Macros]
133
134The following macros are always defined after inclusion of this header, these allow
135integer constants of at least the specified width to be declared:
136INT8_C, UINT8_C, INT16_C, UINT16_C, INT32_C, UINT32_C, INTMAX_C, UINTMAX_C.
137
138The macros INT64_C and UINT64_C are also defined if the the macro BOOST_NO_INT64_T is not defined.
139
140The C99 macro __STDC_CONSTANT_MACROS is also defined as an artifact of the implementation.
141
142For example:
143
144   #include <boost/cstdint.hpp>
145
146   // Here the constant 0x1FFFFFFFF has the correct suffix applied:
147   static const boost::uint64_t c = INT64_C(0x1FFFFFFFF);
148
149[endsect]
150
151[section:intptr Integers for Storing Pointers]
152
153The typedefs [^intptr_t] and [^uintptr_t] defined signed and unsigned integers respectively each capable of storing a pointer.  The macro [^BOOST_HAS_INTPTR_T] is set when these types are available.
154
155[endsect]
156
157
158[endsect]
159