forked from boostorg/config
Merge branch 'master' into develop
This commit is contained in:
@ -50,6 +50,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
[include configuring_boost.qbk]
|
||||
[include macro_reference.qbk]
|
||||
[include cstdint.qbk]
|
||||
[include guidelines.qbk]
|
||||
[include rationale.qbk]
|
||||
[include acknowledgements.qbk]
|
||||
|
139
doc/cstdint.qbk
Normal file
139
doc/cstdint.qbk
Normal file
@ -0,0 +1,139 @@
|
||||
[section:cstdint Standard Integer Types]
|
||||
|
||||
[section Overview]
|
||||
|
||||
The header [^[@../../../../boost/cstdint.hpp <boost/cstdint.hpp>]] provides the typedef's useful
|
||||
for writing portable code that requires certain integer widths. All typedef's are in namespace boost.
|
||||
|
||||
The specifications for these types are based on the ISO/IEC 9899:1999 C Language standard header <stdint.h>.
|
||||
The 64-bit types required by the C standard are ['not required] in the boost header,
|
||||
and may not be supplied for all platforms/compilers, because [^long long] is not [yet] included in the C++ standard.
|
||||
|
||||
See [@../../test/cstdint_test.cpp cstdint_test.cpp] for a test program.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:rationale Rationale]
|
||||
|
||||
The organization of the Boost.Integer headers and classes is designed to take advantage of <stdint.h> types from the
|
||||
1999 C standard without causing undefined behavior in terms of the 1998 C++ standard.
|
||||
The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace [^boost]
|
||||
without placing any names in namespace [^std]. The intension is to complement rather than compete
|
||||
with the C++ Standard Library. Should some future C++ standard include <stdint.h> and <cstdint>,
|
||||
then <boost/cstdint.hpp> will continue to function, but will become redundant and may be safely deprecated.
|
||||
|
||||
Because these are boost headers, their names conform to boost header naming conventions rather than
|
||||
C++ Standard Library header naming conventions.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:ce ['Caveat emptor]]
|
||||
|
||||
As an implementation artifact, certain C <limits.h> macro names may possibly be
|
||||
visible to users of <boost/cstdint.hpp>. Don't use these macros; they are not part of
|
||||
any Boost-specified interface. Use [^boost::integer_traits<>] or [^std::numeric_limits<>] instead.
|
||||
|
||||
As another implementation artifact, certain C <stdint.h> typedef names may possibly be visible
|
||||
in the global namespace to users of <boost/cstdint.hpp>. Don't use these names, they are not part of
|
||||
any Boost-specified interface. Use the respective names in namespace [^boost] instead.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Exact-width integer types]
|
||||
|
||||
The typedef [^int#_t], with # replaced by the width, designates a signed integer type of exactly # bits;
|
||||
for example [^int8_t] denotes an 8-bit signed integer type. Similarly, the typedef [^uint#_t] designates an unsigned
|
||||
integer type of exactly # bits.
|
||||
|
||||
These types are optional. However, if a platform supports integer types with widths of
|
||||
8, 16, 32, 64, or any combination thereof, then <boost/cstdint.hpp> does provide the
|
||||
corresponding typedefs.
|
||||
|
||||
The absence of int64_t and uint64_t is indicated by the macro `BOOST_NO_INT64_T`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Minimum-width integer types]
|
||||
|
||||
The typedef [^int_least#_t], with # replaced by the width, designates a signed integer type with a width
|
||||
of at least # bits, such that no signed integer type with lesser size has at least the specified width.
|
||||
Thus, [^int_least32_t] denotes the smallest signed integer type with a width of at least 32 bits.
|
||||
Similarly, the typedef name [^uint_least#_t] designates an unsigned integer type with a width of at least # bits,
|
||||
such that no unsigned integer type with lesser size has at least the specified width.
|
||||
|
||||
The following minimum-width integer types are provided for all platforms:
|
||||
|
||||
* [^int_least8_t]
|
||||
* [^int_least16_t]
|
||||
* [^int_least32_t]
|
||||
* [^uint_least8_t]
|
||||
* [^uint_least16_t]
|
||||
* [^uint_least32_t]
|
||||
|
||||
The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
|
||||
|
||||
* [^int_least64_t]
|
||||
* [^uint_least64_t]
|
||||
|
||||
|
||||
All other minimum-width integer types are optional.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Fastest minimum-width integer types]
|
||||
|
||||
The typedef [^int_fast#_t], with # replaced by the width, designates the fastest signed integer type
|
||||
with a width of at least # bits. Similarly, the typedef name [^uint_fast#_t] designates the fastest
|
||||
unsigned integer type with a width of at least # bits.
|
||||
|
||||
There is no guarantee that these types are fastest for all purposes. In any case, however, they satisfy
|
||||
the signedness and width requirements.
|
||||
|
||||
The following fastest minimum-width integer types are provided for all platforms:
|
||||
|
||||
* [^int_fast8_t]
|
||||
* [^int_fast16_t]
|
||||
* [^int_fast32_t]
|
||||
* [^uint_fast8_t]
|
||||
* [^uint_fast16_t]
|
||||
* [^uint_fast32_t]
|
||||
|
||||
The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
|
||||
|
||||
* [^int_fast64_t]
|
||||
* [^uint_fast64_t]
|
||||
|
||||
All other fastest minimum-width integer types are optional.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Greatest-width integer types]
|
||||
|
||||
The typedef [^intmax_t ]designates a signed integer type capable of representing any value of any signed integer type.
|
||||
|
||||
The typedef [^uintmax_t] designates an unsigned integer type capable of representing any value of any unsigned integer type.
|
||||
|
||||
These types are provided for all platforms.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Integer Constant Macros]
|
||||
|
||||
The following macros are always defined after inclusion of this header, these allow
|
||||
integer constants of at least the specified width to be declared:
|
||||
INT8_C, UINT8_C, INT16_C, UINT16_C, INT32_C, UINT32_C, INTMAX_C, UINTMAX_C.
|
||||
|
||||
The macros INT64_C and UINT64_C are also defined if the the macro BOOST_NO_INT64_T is not defined.
|
||||
|
||||
The C99 macro __STDC_CONSTANT_MACROS is also defined as an artifact of the implementation.
|
||||
|
||||
For example:
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
// Here the constant 0x1FFFFFFFF has the correct suffix applied:
|
||||
static const boost::uint64_t c = INT64_C(0x1FFFFFFFF);
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
@ -7,7 +7,7 @@
|
||||
<link rel="home" href="../index.html" title="Boost.Config">
|
||||
<link rel="up" href="../index.html" title="Boost.Config">
|
||||
<link rel="prev" href="../index.html" title="Boost.Config">
|
||||
<link rel="next" href="guidelines_for_boost_authors.html" title="Guidelines for Boost Authors">
|
||||
<link rel="next" href="cstdint.html" title="Standard Integer Types">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../index.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>
|
||||
<a accesskey="p" href="../index.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="cstdint.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
@ -5613,7 +5613,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../index.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>
|
||||
<a accesskey="p" href="../index.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="cstdint.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
289
doc/html/boost_config/cstdint.html
Normal file
289
doc/html/boost_config/cstdint.html
Normal file
@ -0,0 +1,289 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Standard Integer Types</title>
|
||||
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Config">
|
||||
<link rel="up" href="../index.html" title="Boost.Config">
|
||||
<link rel="prev" href="boost_macro_reference.html" title="Boost Macro Reference">
|
||||
<link rel="next" href="guidelines_for_boost_authors.html" title="Guidelines for Boost Authors">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="boost_macro_reference.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>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="boost_config.cstdint"></a><a class="link" href="cstdint.html" title="Standard Integer Types">Standard Integer Types</a>
|
||||
</h2></div></div></div>
|
||||
<div class="toc"><dl class="toc">
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.overview">Overview</a></span></dt>
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.rationale">Rationale</a></span></dt>
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.ce"><span class="emphasis"><em>Caveat emptor</em></span></a></span></dt>
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.exact_width_integer_types">Exact-width
|
||||
integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.minimum_width_integer_types">Minimum-width
|
||||
integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.fastest_minimum_width_integer_types">Fastest
|
||||
minimum-width integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.greatest_width_integer_types">Greatest-width
|
||||
integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="cstdint.html#boost_config.cstdint.integer_constant_macros">Integer
|
||||
Constant Macros</a></span></dt>
|
||||
</dl></div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_config.cstdint.overview"></a><a class="link" href="cstdint.html#boost_config.cstdint.overview" title="Overview">Overview</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
The header <code class="literal"><a href="../../../../../boost/cstdint.hpp" target="_top"><boost/cstdint.hpp></a></code>
|
||||
provides the typedef's useful for writing portable code that requires certain
|
||||
integer widths. All typedef's are in namespace boost.
|
||||
</p>
|
||||
<p>
|
||||
The specifications for these types are based on the ISO/IEC 9899:1999 C Language
|
||||
standard header <stdint.h>. The 64-bit types required by the C standard
|
||||
are <span class="emphasis"><em>not required</em></span> in the boost header, and may not be
|
||||
supplied for all platforms/compilers, because <code class="literal">long long</code>
|
||||
is not [yet] included in the C++ standard.
|
||||
</p>
|
||||
<p>
|
||||
See <a href="../../../test/cstdint_test.cpp" target="_top">cstdint_test.cpp</a> for
|
||||
a test program.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_config.cstdint.rationale"></a><a class="link" href="cstdint.html#boost_config.cstdint.rationale" title="Rationale">Rationale</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
The organization of the Boost.Integer headers and classes is designed to
|
||||
take advantage of <stdint.h> types from the 1999 C standard without
|
||||
causing undefined behavior in terms of the 1998 C++ standard. The header
|
||||
<boost/cstdint.hpp> makes the standard integer types safely available
|
||||
in namespace <code class="literal">boost</code> without placing any names in namespace
|
||||
<code class="literal">std</code>. The intension is to complement rather than compete
|
||||
with the C++ Standard Library. Should some future C++ standard include <stdint.h>
|
||||
and <cstdint>, then <boost/cstdint.hpp> will continue to function,
|
||||
but will become redundant and may be safely deprecated.
|
||||
</p>
|
||||
<p>
|
||||
Because these are boost headers, their names conform to boost header naming
|
||||
conventions rather than C++ Standard Library header naming conventions.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<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>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
As an implementation artifact, certain C <limits.h> macro names may
|
||||
possibly be visible to users of <boost/cstdint.hpp>. Don't use these
|
||||
macros; they are not part of any Boost-specified interface. Use <code class="literal">boost::integer_traits<></code>
|
||||
or <code class="literal">std::numeric_limits<></code> instead.
|
||||
</p>
|
||||
<p>
|
||||
As another implementation artifact, certain C <stdint.h> typedef names
|
||||
may possibly be visible in the global namespace to users of <boost/cstdint.hpp>.
|
||||
Don't use these names, they are not part of any Boost-specified interface.
|
||||
Use the respective names in namespace <code class="literal">boost</code> instead.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<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
|
||||
integer types</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
The typedef <code class="literal">int#_t</code>, with # replaced by the width, designates
|
||||
a signed integer type of exactly # bits; for example <code class="literal">int8_t</code>
|
||||
denotes an 8-bit signed integer type. Similarly, the typedef <code class="literal">uint#_t</code>
|
||||
designates an unsigned integer type of exactly # bits.
|
||||
</p>
|
||||
<p>
|
||||
These types are optional. However, if a platform supports integer types with
|
||||
widths of 8, 16, 32, 64, or any combination thereof, then <boost/cstdint.hpp>
|
||||
does provide the corresponding typedefs.
|
||||
</p>
|
||||
<p>
|
||||
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>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<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
|
||||
integer types</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
The typedef <code class="literal">int_least#_t</code>, with # replaced by the width,
|
||||
designates a signed integer type with a width of at least # bits, such that
|
||||
no signed integer type with lesser size has at least the specified width.
|
||||
Thus, <code class="literal">int_least32_t</code> denotes the smallest signed integer
|
||||
type with a width of at least 32 bits. Similarly, the typedef name <code class="literal">uint_least#_t</code>
|
||||
designates an unsigned integer type with a width of at least # bits, such
|
||||
that no unsigned integer type with lesser size has at least the specified
|
||||
width.
|
||||
</p>
|
||||
<p>
|
||||
The following minimum-width integer types are provided for all platforms:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<code class="literal">int_least8_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">int_least16_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">int_least32_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_least8_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_least16_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_least32_t</code>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The following types are available only if, after including <boost/cstdint.hpp>,
|
||||
the macro BOOST_NO_INT64_T is not defined:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<code class="literal">int_least64_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_least64_t</code>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
All other minimum-width integer types are optional.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<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
|
||||
minimum-width integer types</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
The typedef <code class="literal">int_fast#_t</code>, with # replaced by the width,
|
||||
designates the fastest signed integer type with a width of at least # bits.
|
||||
Similarly, the typedef name <code class="literal">uint_fast#_t</code> designates the
|
||||
fastest unsigned integer type with a width of at least # bits.
|
||||
</p>
|
||||
<p>
|
||||
There is no guarantee that these types are fastest for all purposes. In any
|
||||
case, however, they satisfy the signedness and width requirements.
|
||||
</p>
|
||||
<p>
|
||||
The following fastest minimum-width integer types are provided for all platforms:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<code class="literal">int_fast8_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">int_fast16_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">int_fast32_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_fast8_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_fast16_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_fast32_t</code>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The following types are available only if, after including <boost/cstdint.hpp>,
|
||||
the macro BOOST_NO_INT64_T is not defined:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<code class="literal">int_fast64_t</code>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="literal">uint_fast64_t</code>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
All other fastest minimum-width integer types are optional.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<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
|
||||
integer types</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
The typedef <code class="literal">intmax_t </code>designates a signed integer type
|
||||
capable of representing any value of any signed integer type.
|
||||
</p>
|
||||
<p>
|
||||
The typedef <code class="literal">uintmax_t</code> designates an unsigned integer type
|
||||
capable of representing any value of any unsigned integer type.
|
||||
</p>
|
||||
<p>
|
||||
These types are provided for all platforms.
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<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
|
||||
Constant Macros</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
The following macros are always defined after inclusion of this header, these
|
||||
allow integer constants of at least the specified width to be declared: INT8_C,
|
||||
UINT8_C, INT16_C, UINT16_C, INT32_C, UINT32_C, INTMAX_C, UINTMAX_C.
|
||||
</p>
|
||||
<p>
|
||||
The macros INT64_C and UINT64_C are also defined if the the macro BOOST_NO_INT64_T
|
||||
is not defined.
|
||||
</p>
|
||||
<p>
|
||||
The C99 macro __STDC_CONSTANT_MACROS is also defined as an artifact of the
|
||||
implementation.
|
||||
</p>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<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>
|
||||
|
||||
<span class="comment">// Here the constant 0x1FFFFFFFF has the correct suffix applied:</span>
|
||||
<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>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2001-2007 Beman Dawes, Vesa Karvonen, John
|
||||
Maddock<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
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>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="boost_macro_reference.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>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<link rel="home" href="../index.html" title="Boost.Config">
|
||||
<link rel="up" href="../index.html" title="Boost.Config">
|
||||
<link rel="prev" href="boost_macro_reference.html" title="Boost Macro Reference">
|
||||
<link rel="prev" href="cstdint.html" title="Standard Integer Types">
|
||||
<link rel="next" href="rationale.html" title="Rationale">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="boost_macro_reference.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="rationale.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="cstdint.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="rationale.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
@ -371,7 +371,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="boost_macro_reference.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="rationale.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="cstdint.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="rationale.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -77,6 +77,22 @@
|
||||
<dt><span class="section"><a href="boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_for_libraries_with_separate_source_code">Macros
|
||||
for libraries with separate source code</a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html">Standard Integer Types</a></span></dt>
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.overview">Overview</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.rationale">Rationale</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.ce"><span class="emphasis"><em>Caveat emptor</em></span></a></span></dt>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.exact_width_integer_types">Exact-width
|
||||
integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.minimum_width_integer_types">Minimum-width
|
||||
integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.fastest_minimum_width_integer_types">Fastest
|
||||
minimum-width integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.greatest_width_integer_types">Greatest-width
|
||||
integer types</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_config/cstdint.html#boost_config.cstdint.integer_constant_macros">Integer
|
||||
Constant Macros</a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="boost_config/guidelines_for_boost_authors.html">Guidelines for
|
||||
Boost Authors</a></span></dt>
|
||||
<dd><dl>
|
||||
@ -951,7 +967,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: May 31, 2014 at 11:09:07 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: June 01, 2014 at 09:50:01 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -66,6 +66,9 @@ test-suite config
|
||||
[ compile-fail threads/test_thread_fail1.cpp ]
|
||||
[ compile-fail threads/test_thread_fail2.cpp ]
|
||||
[ compile boost_fallthrough_test.cpp : [ check-target-builds has_clang_implicit_fallthrough "Clang implicit fallthrough" : <toolset>clang:<cxxflags>"-std=c++11 -Wimplicit-fallthrough" <warnings-as-errors>on <warnings>all ] ]
|
||||
[ run cstdint_test.cpp : : : <warnings>all <toolset>gcc:<cxxflags>"-Wno-long-long -Wextra" <toolset>darwin:<cxxflags>-Wno-long-long ]
|
||||
[ run cstdint_test2.cpp : : : <warnings>all <toolset>gcc:<cxxflags>"-Wno-long-long -Wextra" <toolset>darwin:<cxxflags>-Wno-long-long ]
|
||||
[ compile cstdint_include_test.cpp : <warnings>all <toolset>gcc:<cxxflags>-Wextra ]
|
||||
;
|
||||
|
||||
obj has_clang_implicit_fallthrough : cmd_line_check.cpp :
|
||||
|
69
test/cstdint_include_test.cpp
Normal file
69
test/cstdint_include_test.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright John Maddock 2009.
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <boost/cstdint.hpp> // must be the only #include!
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::int8_t i8 = INT8_C(0);
|
||||
(void)i8;
|
||||
boost::uint8_t ui8 = UINT8_C(0);
|
||||
(void)ui8;
|
||||
boost::int16_t i16 = INT16_C(0);
|
||||
(void)i16;
|
||||
boost::uint16_t ui16 = UINT16_C(0);
|
||||
(void)ui16;
|
||||
boost::int32_t i32 = INT32_C(0);
|
||||
(void)i32;
|
||||
boost::uint32_t ui32 = UINT32_C(0);
|
||||
(void)ui32;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int64_t i64 = 0;
|
||||
(void)i64;
|
||||
boost::uint64_t ui64 = 0;
|
||||
(void)ui64;
|
||||
#endif
|
||||
boost::int_least8_t i8least = INT8_C(0);
|
||||
(void)i8least;
|
||||
boost::uint_least8_t ui8least = UINT8_C(0);
|
||||
(void)ui8least;
|
||||
boost::int_least16_t i16least = INT16_C(0);
|
||||
(void)i16least;
|
||||
boost::uint_least16_t ui16least = UINT16_C(0);
|
||||
(void)ui16least;
|
||||
boost::int_least32_t i32least = INT32_C(0);
|
||||
(void)i32least;
|
||||
boost::uint_least32_t ui32least = UINT32_C(0);
|
||||
(void)ui32least;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int_least64_t i64least = 0;
|
||||
(void)i64least;
|
||||
boost::uint_least64_t ui64least = 0;
|
||||
(void)ui64least;
|
||||
#endif
|
||||
boost::int_fast8_t i8fast = INT8_C(0);
|
||||
(void)i8fast;
|
||||
boost::uint_fast8_t ui8fast = UINT8_C(0);
|
||||
(void)ui8fast;
|
||||
boost::int_fast16_t i16fast = INT16_C(0);
|
||||
(void)i16fast;
|
||||
boost::uint_fast16_t ui16fast = UINT16_C(0);
|
||||
(void)ui16fast;
|
||||
boost::int_fast32_t i32fast = INT32_C(0);
|
||||
(void)i32fast;
|
||||
boost::uint_fast32_t ui32fast = UINT32_C(0);
|
||||
(void)ui32fast;
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int_fast64_t i64fast = 0;
|
||||
(void)i64fast;
|
||||
boost::uint_fast64_t ui64fast = 0;
|
||||
(void)ui64fast;
|
||||
#endif
|
||||
boost::intmax_t im = 0;
|
||||
(void)im;
|
||||
boost::uintmax_t uim = 0;
|
||||
(void)uim;
|
||||
}
|
238
test/cstdint_test.cpp
Normal file
238
test/cstdint_test.cpp
Normal file
@ -0,0 +1,238 @@
|
||||
// boost cstdint.hpp test program ------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2000. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
// See http://www.boost.org/libs/integer for documentation.
|
||||
|
||||
// Revision History
|
||||
// 11 Sep 01 Adapted to work with macros defined in native stdint.h (John Maddock)
|
||||
// 12 Nov 00 Adapted to merged <boost/cstdint.hpp>
|
||||
// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
|
||||
// 28 Jun 00 Initial version
|
||||
|
||||
//
|
||||
// There are two ways to test this: in version 1, we include cstdint.hpp as the first
|
||||
// include, which means we get decide whether __STDC_CONSTANT_MACROS is defined.
|
||||
// In version two we include stdint.h with __STDC_CONSTANT_MACROS *NOT* defined first,
|
||||
// and check that we still end up with compatible definitions for the INT#_C macros.
|
||||
//
|
||||
// This is version 1.
|
||||
//
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))
|
||||
// We can't suppress this warning on the command line as not all GCC versions support -Wno-type-limits :
|
||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
#endif
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
//
|
||||
// the following class is designed to verify
|
||||
// that the various INTXX_C macros can be used
|
||||
// in integral constant expressions:
|
||||
//
|
||||
struct integral_constant_checker
|
||||
{
|
||||
static const boost::int8_t int8 = INT8_C(-127);
|
||||
static const boost::int_least8_t int_least8 = INT8_C(-127);
|
||||
static const boost::int_fast8_t int_fast8 = INT8_C(-127);
|
||||
|
||||
static const boost::uint8_t uint8 = UINT8_C(255);
|
||||
static const boost::uint_least8_t uint_least8 = UINT8_C(255);
|
||||
static const boost::uint_fast8_t uint_fast8 = UINT8_C(255);
|
||||
|
||||
static const boost::int16_t int16 = INT16_C(-32767);
|
||||
static const boost::int_least16_t int_least16 = INT16_C(-32767);
|
||||
static const boost::int_fast16_t int_fast16 = INT16_C(-32767);
|
||||
|
||||
static const boost::uint16_t uint16 = UINT16_C(65535);
|
||||
static const boost::uint_least16_t uint_least16 = UINT16_C(65535);
|
||||
static const boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
|
||||
|
||||
static const boost::int32_t int32 = INT32_C(-2147483647);
|
||||
static const boost::int_least32_t int_least32 = INT32_C(-2147483647);
|
||||
static const boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
|
||||
|
||||
static const boost::uint32_t uint32 = UINT32_C(4294967295);
|
||||
static const boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
|
||||
static const boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
|
||||
|
||||
static void check();
|
||||
};
|
||||
|
||||
void integral_constant_checker::check()
|
||||
{
|
||||
BOOST_TEST( int8 == -127 );
|
||||
BOOST_TEST( int_least8 == -127 );
|
||||
BOOST_TEST( int_fast8 == -127 );
|
||||
BOOST_TEST( uint8 == 255u );
|
||||
BOOST_TEST( uint_least8 == 255u );
|
||||
BOOST_TEST( uint_fast8 == 255u );
|
||||
BOOST_TEST( int16 == -32767 );
|
||||
BOOST_TEST( int_least16 == -32767 );
|
||||
BOOST_TEST( int_fast16 == -32767 );
|
||||
BOOST_TEST( uint16 == 65535u );
|
||||
BOOST_TEST( uint_least16 == 65535u );
|
||||
BOOST_TEST( uint_fast16 == 65535u );
|
||||
BOOST_TEST( int32 == -2147483647 );
|
||||
BOOST_TEST( int_least32 == -2147483647 );
|
||||
BOOST_TEST( int_fast32 == -2147483647 );
|
||||
BOOST_TEST( uint32 == 4294967295u );
|
||||
BOOST_TEST( uint_least32 == 4294967295u );
|
||||
BOOST_TEST( uint_fast32 == 4294967295u );
|
||||
}
|
||||
#endif // BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
|
||||
//
|
||||
// the following function simply verifies that the type
|
||||
// of an integral constant is correctly defined:
|
||||
//
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option -w-8008
|
||||
#pragma option -w-8066
|
||||
#endif
|
||||
template <class T1, class T2>
|
||||
void integral_constant_type_check(T1, T2)
|
||||
{
|
||||
//
|
||||
// the types T1 and T2 may not be exactly
|
||||
// the same type, but they should be the
|
||||
// same size and signedness. We could use
|
||||
// numeric_limits to verify this, but
|
||||
// numeric_limits implementations currently
|
||||
// vary too much, or are incomplete or missing.
|
||||
//
|
||||
T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
|
||||
T2 t2 = static_cast<T2>(-1); // ditto
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// if we have a native stdint.h
|
||||
// then the INTXX_C macros may define
|
||||
// a type that's wider than required:
|
||||
BOOST_TEST(sizeof(T1) <= sizeof(T2));
|
||||
#else
|
||||
BOOST_TEST(sizeof(T1) == sizeof(T2));
|
||||
BOOST_TEST(t1 == t2);
|
||||
#endif
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// native headers are permitted to promote small
|
||||
// unsigned types to type int:
|
||||
if(sizeof(T1) >= sizeof(int))
|
||||
{
|
||||
if(t1 > 0)
|
||||
BOOST_TEST(t2 > 0);
|
||||
else
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
}
|
||||
else if(t1 < 0)
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
#else
|
||||
if(t1 > 0)
|
||||
BOOST_TEST(t2 > 0);
|
||||
else
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
integral_constant_checker::check();
|
||||
#endif
|
||||
//
|
||||
// verify the types of the integral constants:
|
||||
//
|
||||
integral_constant_type_check(boost::int8_t(0), INT8_C(0));
|
||||
integral_constant_type_check(boost::uint8_t(0), UINT8_C(0));
|
||||
integral_constant_type_check(boost::int16_t(0), INT16_C(0));
|
||||
integral_constant_type_check(boost::uint16_t(0), UINT16_C(0));
|
||||
integral_constant_type_check(boost::int32_t(0), INT32_C(0));
|
||||
integral_constant_type_check(boost::uint32_t(0), UINT32_C(0));
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
integral_constant_type_check(boost::int64_t(0), INT64_C(0));
|
||||
integral_constant_type_check(boost::uint64_t(0), UINT64_C(0));
|
||||
#endif
|
||||
//
|
||||
boost::int8_t int8 = INT8_C(-127);
|
||||
boost::int_least8_t int_least8 = INT8_C(-127);
|
||||
boost::int_fast8_t int_fast8 = INT8_C(-127);
|
||||
|
||||
boost::uint8_t uint8 = UINT8_C(255);
|
||||
boost::uint_least8_t uint_least8 = UINT8_C(255);
|
||||
boost::uint_fast8_t uint_fast8 = UINT8_C(255);
|
||||
|
||||
boost::int16_t int16 = INT16_C(-32767);
|
||||
boost::int_least16_t int_least16 = INT16_C(-32767);
|
||||
boost::int_fast16_t int_fast16 = INT16_C(-32767);
|
||||
|
||||
boost::uint16_t uint16 = UINT16_C(65535);
|
||||
boost::uint_least16_t uint_least16 = UINT16_C(65535);
|
||||
boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
|
||||
|
||||
boost::int32_t int32 = INT32_C(-2147483647);
|
||||
boost::int_least32_t int_least32 = INT32_C(-2147483647);
|
||||
boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
|
||||
|
||||
boost::uint32_t uint32 = UINT32_C(4294967295);
|
||||
boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
|
||||
boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
|
||||
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int64_t int64 = INT64_C(-9223372036854775807);
|
||||
boost::int_least64_t int_least64 = INT64_C(-9223372036854775807);
|
||||
boost::int_fast64_t int_fast64 = INT64_C(-9223372036854775807);
|
||||
|
||||
boost::uint64_t uint64 = UINT64_C(18446744073709551615);
|
||||
boost::uint_least64_t uint_least64 = UINT64_C(18446744073709551615);
|
||||
boost::uint_fast64_t uint_fast64 = UINT64_C(18446744073709551615);
|
||||
|
||||
boost::intmax_t intmax = INTMAX_C(-9223372036854775807);
|
||||
boost::uintmax_t uintmax = UINTMAX_C(18446744073709551615);
|
||||
#else
|
||||
boost::intmax_t intmax = INTMAX_C(-2147483647);
|
||||
boost::uintmax_t uintmax = UINTMAX_C(4294967295);
|
||||
#endif
|
||||
|
||||
BOOST_TEST( int8 == -127 );
|
||||
BOOST_TEST( int_least8 == -127 );
|
||||
BOOST_TEST( int_fast8 == -127 );
|
||||
BOOST_TEST( uint8 == 255u );
|
||||
BOOST_TEST( uint_least8 == 255u );
|
||||
BOOST_TEST( uint_fast8 == 255u );
|
||||
BOOST_TEST( int16 == -32767 );
|
||||
BOOST_TEST( int_least16 == -32767 );
|
||||
BOOST_TEST( int_fast16 == -32767 );
|
||||
BOOST_TEST( uint16 == 65535u );
|
||||
BOOST_TEST( uint_least16 == 65535u );
|
||||
BOOST_TEST( uint_fast16 == 65535u );
|
||||
BOOST_TEST( int32 == -2147483647 );
|
||||
BOOST_TEST( int_least32 == -2147483647 );
|
||||
BOOST_TEST( int_fast32 == -2147483647 );
|
||||
BOOST_TEST( uint32 == 4294967295u );
|
||||
BOOST_TEST( uint_least32 == 4294967295u );
|
||||
BOOST_TEST( uint_fast32 == 4294967295u );
|
||||
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
BOOST_TEST( int64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( int_least64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( int_fast64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( uint64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( uint_least64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( uint_fast64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( intmax == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( uintmax == UINT64_C(18446744073709551615) );
|
||||
#else
|
||||
BOOST_TEST( intmax == -2147483647 );
|
||||
BOOST_TEST( uintmax == 4294967295u );
|
||||
#endif
|
||||
|
||||
|
||||
std::cout << "OK\n";
|
||||
return boost::report_errors();
|
||||
}
|
248
test/cstdint_test2.cpp
Normal file
248
test/cstdint_test2.cpp
Normal file
@ -0,0 +1,248 @@
|
||||
// boost cstdint.hpp test program ------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2000. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
// See http://www.boost.org/libs/integer for documentation.
|
||||
|
||||
// Revision History
|
||||
// 11 Sep 01 Adapted to work with macros defined in native stdint.h (John Maddock)
|
||||
// 12 Nov 00 Adapted to merged <boost/cstdint.hpp>
|
||||
// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
|
||||
// 28 Jun 00 Initial version
|
||||
|
||||
//
|
||||
// There are two ways to test this: in version 1, we include cstdint.hpp as the first
|
||||
// include, which means we get decide whether __STDC_CONSTANT_MACROS is defined.
|
||||
// In version two we include stdint.h with __STDC_CONSTANT_MACROS *NOT* defined first,
|
||||
// and check that we still end up with compatible definitions for the INT#_C macros.
|
||||
//
|
||||
// This is version 2.
|
||||
//
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))
|
||||
// We can't suppress this warning on the command line as not all GCC versions support -Wno-type-limits :
|
||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_STDINT_H
|
||||
#ifdef __hpux
|
||||
# include <inttypes.h>
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
//
|
||||
// the following class is designed to verify
|
||||
// that the various INTXX_C macros can be used
|
||||
// in integral constant expressions:
|
||||
//
|
||||
struct integral_constant_checker
|
||||
{
|
||||
static const boost::int8_t int8 = INT8_C(-127);
|
||||
static const boost::int_least8_t int_least8 = INT8_C(-127);
|
||||
static const boost::int_fast8_t int_fast8 = INT8_C(-127);
|
||||
|
||||
static const boost::uint8_t uint8 = UINT8_C(255);
|
||||
static const boost::uint_least8_t uint_least8 = UINT8_C(255);
|
||||
static const boost::uint_fast8_t uint_fast8 = UINT8_C(255);
|
||||
|
||||
static const boost::int16_t int16 = INT16_C(-32767);
|
||||
static const boost::int_least16_t int_least16 = INT16_C(-32767);
|
||||
static const boost::int_fast16_t int_fast16 = INT16_C(-32767);
|
||||
|
||||
static const boost::uint16_t uint16 = UINT16_C(65535);
|
||||
static const boost::uint_least16_t uint_least16 = UINT16_C(65535);
|
||||
static const boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
|
||||
|
||||
static const boost::int32_t int32 = INT32_C(-2147483647);
|
||||
static const boost::int_least32_t int_least32 = INT32_C(-2147483647);
|
||||
static const boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
|
||||
|
||||
static const boost::uint32_t uint32 = UINT32_C(4294967295);
|
||||
static const boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
|
||||
static const boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
|
||||
|
||||
static void check();
|
||||
};
|
||||
|
||||
void integral_constant_checker::check()
|
||||
{
|
||||
BOOST_TEST( int8 == -127 );
|
||||
BOOST_TEST( int_least8 == -127 );
|
||||
BOOST_TEST( int_fast8 == -127 );
|
||||
BOOST_TEST( uint8 == 255u );
|
||||
BOOST_TEST( uint_least8 == 255u );
|
||||
BOOST_TEST( uint_fast8 == 255u );
|
||||
BOOST_TEST( int16 == -32767 );
|
||||
BOOST_TEST( int_least16 == -32767 );
|
||||
BOOST_TEST( int_fast16 == -32767 );
|
||||
BOOST_TEST( uint16 == 65535u );
|
||||
BOOST_TEST( uint_least16 == 65535u );
|
||||
BOOST_TEST( uint_fast16 == 65535u );
|
||||
BOOST_TEST( int32 == -2147483647 );
|
||||
BOOST_TEST( int_least32 == -2147483647 );
|
||||
BOOST_TEST( int_fast32 == -2147483647 );
|
||||
BOOST_TEST( uint32 == 4294967295u );
|
||||
BOOST_TEST( uint_least32 == 4294967295u );
|
||||
BOOST_TEST( uint_fast32 == 4294967295u );
|
||||
}
|
||||
#endif // BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
|
||||
//
|
||||
// the following function simply verifies that the type
|
||||
// of an integral constant is correctly defined:
|
||||
//
|
||||
#ifdef __BORLANDC__
|
||||
#pragma option -w-8008
|
||||
#pragma option -w-8066
|
||||
#endif
|
||||
template <class T1, class T2>
|
||||
void integral_constant_type_check(T1, T2)
|
||||
{
|
||||
//
|
||||
// the types T1 and T2 may not be exactly
|
||||
// the same type, but they should be the
|
||||
// same size and signedness. We could use
|
||||
// numeric_limits to verify this, but
|
||||
// numeric_limits implementations currently
|
||||
// vary too much, or are incomplete or missing.
|
||||
//
|
||||
T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
|
||||
T2 t2 = static_cast<T2>(-1); // ditto
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// if we have a native stdint.h
|
||||
// then the INTXX_C macros may define
|
||||
// a type that's wider than required:
|
||||
BOOST_TEST(sizeof(T1) <= sizeof(T2));
|
||||
#else
|
||||
BOOST_TEST(sizeof(T1) == sizeof(T2));
|
||||
BOOST_TEST(t1 == t2);
|
||||
#endif
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// native headers are permitted to promote small
|
||||
// unsigned types to type int:
|
||||
if(sizeof(T1) >= sizeof(int))
|
||||
{
|
||||
if(t1 > 0)
|
||||
BOOST_TEST(t2 > 0);
|
||||
else
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
}
|
||||
else if(t1 < 0)
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
#else
|
||||
if(t1 > 0)
|
||||
BOOST_TEST(t2 > 0);
|
||||
else
|
||||
BOOST_TEST(!(t2 > 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
integral_constant_checker::check();
|
||||
#endif
|
||||
//
|
||||
// verify the types of the integral constants:
|
||||
//
|
||||
integral_constant_type_check(boost::int8_t(0), INT8_C(0));
|
||||
integral_constant_type_check(boost::uint8_t(0), UINT8_C(0));
|
||||
integral_constant_type_check(boost::int16_t(0), INT16_C(0));
|
||||
integral_constant_type_check(boost::uint16_t(0), UINT16_C(0));
|
||||
integral_constant_type_check(boost::int32_t(0), INT32_C(0));
|
||||
integral_constant_type_check(boost::uint32_t(0), UINT32_C(0));
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
integral_constant_type_check(boost::int64_t(0), INT64_C(0));
|
||||
integral_constant_type_check(boost::uint64_t(0), UINT64_C(0));
|
||||
#endif
|
||||
//
|
||||
boost::int8_t int8 = INT8_C(-127);
|
||||
boost::int_least8_t int_least8 = INT8_C(-127);
|
||||
boost::int_fast8_t int_fast8 = INT8_C(-127);
|
||||
|
||||
boost::uint8_t uint8 = UINT8_C(255);
|
||||
boost::uint_least8_t uint_least8 = UINT8_C(255);
|
||||
boost::uint_fast8_t uint_fast8 = UINT8_C(255);
|
||||
|
||||
boost::int16_t int16 = INT16_C(-32767);
|
||||
boost::int_least16_t int_least16 = INT16_C(-32767);
|
||||
boost::int_fast16_t int_fast16 = INT16_C(-32767);
|
||||
|
||||
boost::uint16_t uint16 = UINT16_C(65535);
|
||||
boost::uint_least16_t uint_least16 = UINT16_C(65535);
|
||||
boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
|
||||
|
||||
boost::int32_t int32 = INT32_C(-2147483647);
|
||||
boost::int_least32_t int_least32 = INT32_C(-2147483647);
|
||||
boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
|
||||
|
||||
boost::uint32_t uint32 = UINT32_C(4294967295);
|
||||
boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
|
||||
boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
|
||||
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
boost::int64_t int64 = INT64_C(-9223372036854775807);
|
||||
boost::int_least64_t int_least64 = INT64_C(-9223372036854775807);
|
||||
boost::int_fast64_t int_fast64 = INT64_C(-9223372036854775807);
|
||||
|
||||
boost::uint64_t uint64 = UINT64_C(18446744073709551615);
|
||||
boost::uint_least64_t uint_least64 = UINT64_C(18446744073709551615);
|
||||
boost::uint_fast64_t uint_fast64 = UINT64_C(18446744073709551615);
|
||||
|
||||
boost::intmax_t intmax = INTMAX_C(-9223372036854775807);
|
||||
boost::uintmax_t uintmax = UINTMAX_C(18446744073709551615);
|
||||
#else
|
||||
boost::intmax_t intmax = INTMAX_C(-2147483647);
|
||||
boost::uintmax_t uintmax = UINTMAX_C(4294967295);
|
||||
#endif
|
||||
|
||||
BOOST_TEST( int8 == -127 );
|
||||
BOOST_TEST( int_least8 == -127 );
|
||||
BOOST_TEST( int_fast8 == -127 );
|
||||
BOOST_TEST( uint8 == 255u );
|
||||
BOOST_TEST( uint_least8 == 255u );
|
||||
BOOST_TEST( uint_fast8 == 255u );
|
||||
BOOST_TEST( int16 == -32767 );
|
||||
BOOST_TEST( int_least16 == -32767 );
|
||||
BOOST_TEST( int_fast16 == -32767 );
|
||||
BOOST_TEST( uint16 == 65535u );
|
||||
BOOST_TEST( uint_least16 == 65535u );
|
||||
BOOST_TEST( uint_fast16 == 65535u );
|
||||
BOOST_TEST( int32 == -2147483647 );
|
||||
BOOST_TEST( int_least32 == -2147483647 );
|
||||
BOOST_TEST( int_fast32 == -2147483647 );
|
||||
BOOST_TEST( uint32 == 4294967295u );
|
||||
BOOST_TEST( uint_least32 == 4294967295u );
|
||||
BOOST_TEST( uint_fast32 == 4294967295u );
|
||||
|
||||
#ifndef BOOST_NO_INT64_T
|
||||
BOOST_TEST( int64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( int_least64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( int_fast64 == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( uint64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( uint_least64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( uint_fast64 == UINT64_C(18446744073709551615) );
|
||||
BOOST_TEST( intmax == INT64_C(-9223372036854775807) );
|
||||
BOOST_TEST( uintmax == UINT64_C(18446744073709551615) );
|
||||
#else
|
||||
BOOST_TEST( intmax == -2147483647 );
|
||||
BOOST_TEST( uintmax == 4294967295u );
|
||||
#endif
|
||||
|
||||
|
||||
std::cout << "OK\n";
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user