int always 32 bits on all platforms?

Jason House jason.james.house at gmail.com
Wed Oct 21 15:44:14 PDT 2009


AJ Wrote:

> 
> "BCS" <none at anon.com> wrote in message 
> news:a6268ffbadb8cc20772570e4f0 at news.digitalmars.com...
> > 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.
> 
> I wasn't thinking about math issues, but rather struct field 
> alignment/portability, and platform alignment requirements for basic types, 
> issues. I'm guessing that it is all worked out by the compiler, so that 
> makes the development of a compiler more difficult, if so, but how much more 
> difficult? A simple example or description of how this is done would really 
> be great. (BTW, this is definitely an area where I would approve of more 
> language implementation complexity for the great strides in programming 
> efficiency (and fun!) it gives).
> 
> 
> 

In D, both type size and alignment have the same defaults on all platforms. If desired, alignment can be explicitly controlled with the align attribute. Similarly, use of specific types control sizes.



More information about the Digitalmars-d mailing list