int always 32 bits on all platforms?
Nick Sabalausky
a at a.a
Wed Oct 21 21:34:09 PDT 2009
"AJ" <aj at nospam.net> wrote in message news:hboaeu$5sk$1 at digitalmars.com...
>
> "BCS" <none at anon.com> wrote in message
> news:a6268ffbb0a8cc20817fe1f1c2 at news.digitalmars.com...
>> Hello aJ,
>>
>>> I would think so. Anyway, what I find compelling about guaranteed
>>> widths is the potential to eliminate alignment and padding issues
>>> (that is, be able to control it with confidence across platforms as
>>> one already can on a single platform via compiler pragmas or cmdline
>>> switches).
>>>
>>
>> Ah! I thought you were taking issue with something. D has that and gets
>> most of the porting stuff to work.
>>
>
> It does? Get this to work on "all" platforms:
>
> struct ABC
> {
> byte a;
> int b; // may be improperly aligned on some platforms
> int64 c; // same issue
> };
>
>
// Guarantee packed on all platforms
align() struct ABC
{
byte a;
int b; // may be improperly aligned on some platforms
int64 c; // same issue
};
// Guarantee 64-bit alignment on a, b, and c on all platforms
align(8) struct ABC
{
byte a;
int b; // may be improperly aligned on some platforms
int64 c; // same issue
};
More information about the Digitalmars-d
mailing list