|
Boost : |
From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-07-28 14:27:26
From: Beman Dawes <beman_at_[hidden]>
> Background: The new C9X C Langauge standard has added a header
> <stdint.h> which declares integer types with specified widths and
> corresponding MIN/MAX macros. The typedefs have names like int32_t,
> int_least32_t, int_fast32_t, and intmax_t. The C++ standard doesn't
> supply this header.
>
> The Question: How can Boost authors access specified width integers?
> (This isn't theoretical; there are at least two boost projects
> underway that need specific integer widths.)
>
> Possible answers:
>
> 1) #include <stdint.h>, and supply a version for systems which don't
> already have one. Cons: The names go in the global namespace, and it
> seems like a C rather than C++ solution.
>
> 2) #include <cstdint>, and supply a version (with names in namespace
> std) for systems which don't already have one. At least one compiler
> vendor is already doing this. Pros: Minimum future impact if C++
> eventually standardizes <cstdint>. Cons: The C++ committee may never
> standardize <cstdint> or may standardize it in a way incompatible
> with C. (These seem low probability, or even very low probability,
> events, IMO.)
I'm not sure that on all systems you can make this work -- you
may not be able to have a header without an extension, or you may
not be able to put your own stuff on the system path.
> 3) #include <boost/stdint.hpp>, and supply same. Names in namespace
> boost. Cons: If <cstdint> becomes either common or standardized,
> Boost is out-of-step.
So I assume you mean "boost/stdint.hpp". As long as this can be
implemented in terms of <stdint.h> or <cstdint> then we aren't
out of step.
> 4) #include <boost/our_name.hpp>, and supply same. Namespace boost,
> and use names different from <stdint.h> names. Cons: Why fight a
> standard? Boost should support existing standards, even if a bit
> uncomfortable.
> 5) and 6) Too brain-dead to bother explaining.
>
> At first, I only considered (3), but then in came a compiler release
> with <cstdint> supplied. It took some getting used to, but now (2)
> is starting to look better. I don't really like (1) or (4) for the
> reasons stated.
>
> Comments?
I'd add option 7: A <boost/stdint.hpp> that puts the names in
std, eventually to be just something like:
#ifndef BOOST_STDINT_HPP
#define BOOST_STDINT_HPP
#include <cstdint>
#endif
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk