"Timon Gehr" <[email protected]> wrote in message 
news:[email protected]...
>> Nick Sabalausky:
>>
>>> In D2, I can treat a uint as an array of ubytes by doing this:
>>>
>>> uint num = /+...whatever...+/;
>>> ubyte[] = cast(ubyte[4])num;
>>>
>>> How do I do that in D1?
>>
>> Using a union is probably the safest way:
>>
>> union Uint2Ubyte {
>>     uint u;
>>     ubyte[4] b;
>> }
>>
>> By the way, this of type conversions is a shady area in D.
>>
>> Bye,
>> bearophile
>
> I think it is no so shady after all:
> I tested the following code in DMD 2.053:
> void main(){
>    uint a;
>    ubyte[] b = cast(ubyte[4])a;
> }
>
> It gives the same error as in D1.
>

Ok, that's just bizarre. I've just check and verified that you're right. But 
I could swear I've done that sort of thing before, and without using the 
pointer trick Steve pointed out...



Reply via email to