int always 32 bits on all platforms?

AJ aj at nospam.net
Thu Oct 22 12:46:35 PDT 2009


"BCS" <none at anon.com> wrote in message 
news:a6268ffbc0a8cc210e3ccb7da8 at news.digitalmars.com...
> Hello aJ,
>
>> Well I can do the same thing with pragma or compiler switch in C++.
>> It doesn't mean that thing will work if 32-bit ints have to be aligned
>> on 32-bit boundaries. While nice to have one syntax to do that, it
>> doesn't fix the "problem" (which I haven't expressed correctly
>> probably). What good is a packed structure that has misaligned data
>> members for the platform?
>
> You end up with mutually exclusive goals for different systems: align to 
> (depending on the CPU) 8/16/32/64 bits and make it compact. You just can't 
> have both in all cases.

I knew that, I just wanted to be sure I did.

>
> Generally I would expect you get one of three cases: 1) you need to ship 
> binary struct from one system to another so you need to match a given 
> layout from a different system (in this case avoiding misaligned data is a 
> matter of luck), 2) you never ship the data out of the process (just skip 
> all the align directives and let DMD align stuff correctly as, I think, it 
> does by default) or 3) you need packed data (uses align to align on 8 
> bits)
>

#1 is Nirvana. 





More information about the Digitalmars-d mailing list