That's what I call "comfort limitation"; if you want to do strange things, you
have some more coding effort, but you get more optimization on "normal" things.
Maybe the union is also clearer from the documentation point of view.
Kind regards
Bernd
Am 05.01.2014 13:26, schrieb J.H.
> Hear! Hear!
>
> On 01/05/2014 01:23 PM, Bernd Oppolzer wrote:
>> another thought:
>>
>> if you want to do such overlays with the ANSIALIAS option switched on,
>> I believe you can do it using unions.
>>
>> That is, a union that contains both the unsigned long and the unsigned
>> short field, then you assign first the unsigned long 111, then the unsigned
>> short 222, then you print the unsigned long.
>>
>> This way the compiler must generate code for both assignments,
>> even if ANSIALIAS is on. Because it is the same type of object (the union).
>>
>> Of course, the outcome will depend upon the representation on the platform,
>> for example, endianness.
>>
>> This, IMHO, is the way, to make your code ANSIALIAS-safe, while still being
>> able to do storage overlays. The pointers must be pointers to the unions,
>> not pointers to the components, and then the proper component is selected.
>>
>> Kind regards
>>
>> Bernd
>>
|