[cfe-dev] Inconsistent types used to represent bitwidth

Hartmut Kaiser hartmut.kaiser at gmail.com
Wed Oct 3 17:17:04 PDT 2007


Chris, 

> > I'm currently trying to remove some of the warnings spit 
> out on me by 
> > the
> > VC++ compiler (mostly warnings about possible loss of precision) and
> > recognized, that the bitwith (size of a type in bits) is 
> represented 
> > using different types all over the place: sometimes unsigned, 
> > sometimes uint32_t and sometimes it's even uint64_t. I really would 
> > like to change that to a more consistent scheme, but need 
> some advice 
> > which type to choose.
> > Since I
> > think we can't expect to get anything terribly large as the 
> bitwidth 
> > of a type I'ld say let's go for uint32_t.
> 
> Hi Hartmut,
> 
> We should go with uint64_t in general.  There can be large 
> arrays (for example) on 64-bit targets that need this.  For 
> "known little things" like integer types, uint32_t would be 
> sufficient, but it is probably better to be consistent and 
> use uint64_t for everything.

IIUC, the bitwidth is most of the time the number of bits needed to
represent the size, i.e. 32 for uint32_t. In this case 64 is the largest
number these kind of variables will ever hold, no?

Regards Hartmut





More information about the cfe-dev mailing list