int always 32 bits on all platforms?

BCS none at anon.com
Wed Oct 21 15:06:05 PDT 2009


Hello aJ,

> How can/does D guarantee that "int" will always be 32 bits on all
> platforms? Does this mean that D won't work on some platforms?


D is not built for 8 or 16 bit systems. However 32 bit math can be done on 
a 16 bit CPU, it's just slow. In the other direction, 32 bit math (and 16 
and 8 bit) can be done on a 64 bit CPU so that's not a problem. If you really 
want the machine word size (and expecting code that does that to port is 
foolish) use size_t. 

> Why is
> integer width so ambiguous in C/C++? (I am using "platform" as
> equivalent to CPU+OS+compiler).
> 

In C IIRC the rule is: "native text item" == char <= short <= int <= long. 
This is a result of legacy issues from WAY back when (I think).





More information about the Digitalmars-d mailing list