Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2004-10-15 05:26:50

> According to the docs there is no Boost.Config macro telling me if
> 'int64_t' in fact is an alias to 'long long' or not.

Correct: int64_t and uint64_t are only defined by us if there is no platform
<stdint.h>, and if we don't define those types then we don't know what the
"real" type of these are. They are defined to be the smallest 64-bit
integral type BTW, so int is prefered over long is prefered over long long.

> Is one of the above possibilities always and for every compiler guaranteed
> ?
> The documentation does not say too much about MS_INT64_T, either.
> Is it about the name '__int64' instead of 'int64_t' ?

No, it's used to to help implement int64_t. It tells you that __int64 is an
intrinsic type, that's all.

> Does a Boost.Config user really have to check all these different
> spellings of 64 bit types like for example:
> support long_long_type
> support ulong_long_type
> #elif defined(BOOST_HAS_INT64_T)
> support int64_t
> support uint64_t
> #elif defined(BOOST_HAS_MS_INT64_T)
> support __int64
> support unsigned __int64
> #endif


Just check BOOST_NO_INT64_T after including <boost/cstdint.hpp> and then use
[u]stdint_t if you want a 64-bit integer type.

> The example assumes there is only one signed/unsigned pair of intrinsic 64
> bit integers - as I mentioned before I have no idea if this is always the
> case.

Do you mean more than one type? If so then yes there may be many 64-bit
integral types - especially if int or long are 64-bit types.

> Consider the "support for type" in this example is in fact something like
> template specialization or overloading a function, where it would trigger
> an ambiguity situation using separate #if(n)defS ...

That's what BOOST_HAS_LONG_LONG and BOOST_HAS_MS_INT64 are for - see
is_integer for an example of use:

template <class T> is_integral{...};

template<> is_integral<unsigned char>{...};
// etc
template<> is_integral<long long>{...};
template<> is_integral<unsigned long long>{...};
#elif defined(BOOST_HAS_MS_INT64)
template<> is_integral<__int64>{...};
template<> is_integral<unsigned __int64>{...};

Note these macros should only be used when overloading/specialising for all
intrinsic types, such usage should probably be infequent IMO.

> However, is there a possibility to reduce the painful work a user has to
> go through to support 64 bit types properly, somehow (probably by using a
> typedef alias like done for long_long_type, already) ?

I doubt it, and it's not painful once you get your head around what the
macros actually mean, honestly ;-)


Boost list run by bdawes at, gregod at, cpdaniel at, john at