Boost logo

Boost Users :

Subject: Re: [Boost-users] How to find: best integer type for processor
From: Daniel Krügler (dsp_at_[hidden])
Date: 2008-10-31 03:42:29


Scott McMurray wrote:
> On Thu, Oct 30, 2008 at 13:08, Othman, Ossama <ossama.othman_at_[hidden]> wrote:
>>> If you want the largest native integer, though not 100% portable to
>>> weird archs, this should work in x86/x64 and most others:
>>>
>>> typedef boost::int_t<sizeof(void*) * 8>::fast fastint_t;
>> Why not just use the standard {u}intptr_t or {u}intmax_t typedef in this case?
>>
>
> For intptr_t, this message comes to mind:
> http://lists.boost.org/Archives/boost/2005/09/94158.php

True, but IMO it is an error in the C standard, that it did not add
a similar statement for (u)intptr_t as it does for the
exact integer types (u)intN_t, which says in 7.18.1.1/3:

"These types are optional. However, if an implementation provides
integer types with widths of 8, 16, 32, or 64 bits, no padding bits,
and (for the signed types) that have a two’s complement representation,
it shall define the corresponding typedef names."

If this had been done, you could always use (u)intptr_t where
boost::int_t<sizeof(void*) * CHAR_BIT>::fast would be a feasible
instantiation.

Side note: Is anyone aware of the proper forum/contact person to
address this issue to persons near to the C standard?

Just my 2 euro cents,

Daniel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net