static array casting

Hoenir mrmocool at gmx.de
Tue Apr 1 04:11:44 PDT 2008


Jarrett Billingsley schrieb:
> 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.
> 
Yes I use it 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.
> 
Yes, the error is "Error: non-constant expression cast(RGBA [256u])"

> As a weird workaround, you can do this:
> 
> RGBA[256] Pal = (cast(RGBA[])[ ... ])[0 .. 256]; 
> 
I already considered using slicing but didn't get it to work. Thank you :)


More information about the Digitalmars-d-learn mailing list