static array casting
Jarrett Billingsley
kb3ctd2 at yahoo.com
Thu Mar 27 15:18:59 PDT 2008
"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message
news:fsh6bs$23oi$1 at digitalmars.com...
> "Hoenir" <mrmocool at gmx.de> wrote in message
> news:fsgsed$18s3$1 at digitalmars.com...
>> Why does
>>
>> RGBA[] PALETTE = cast(RGBA[]) [
>> 0x00, 0x00, 0x00, 0x00, 0xE3, 0x53, 0x00, 0x00,...... ];
>>
>> work, but
>>
>> RGBA[256] PALETTE = cast(RGBA[256]) [
>> 0x00, 0x00, 0x00, 0x00, 0xE3, 0x53, 0x00, 0x00,...];
>>
>> doesn't?
>> RGBA simply is a struct containing r,g,b and a as ubytes.
>
> Works for me. Are you sure you have exactly 1024 values in that array?
Stupid OE.
You weren't very clear on what what was happening. It works when it's in a
function, but not when declared at global scope.
As for why it fails with a stupid "non-const expression" error? Who knows.
Probably a bug. Maybe it's already committed.
As a weird workaround, you can do this:
RGBA[256] Pal = (cast(RGBA[])[ ... ])[0 .. 256];
More information about the Digitalmars-d-learn
mailing list