"AJ" <[email protected]> wrote in message news:[email protected]...
>
> "Chris Nicholson-Sauls" <[email protected]> wrote in message 
> news:[email protected]...
>> AJ wrote:
>>> "Nick Sabalausky" <[email protected]> wrote in message 
>>> news:[email protected]...
>>>> "AJ" <[email protected]> wrote in message 
>>>> news:[email protected]...
>>>>> "BCS" <[email protected]> wrote in message 
>>>>> news:[email protected]...
>>>>>> 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
>>>> };
>>>
>>> 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?
>>>
>>
>> struct ABC {
>> version (RequireAlign4) align(4)
>> byte a;
>> int b;
>> int64 c;
>> }
>>
>
> Please 'splain the above.

http://www.digitalmars.com/d/1.0/attribute.html#align
http://www.digitalmars.com/d/1.0/version.html#version
http://dictionary.reference.com/browse/explain?r=75


Reply via email to