AA within struct

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Feb 15 06:11:46 PST 2008


"dominik" <aha at aha.com> wrote in message 
news:fp3s4m$srr$1 at digitalmars.com...

> align(1)
> struct DST {
>
>    private int test;
>    private char[] secondtest;
>
>    public static DST[char[]] AA =
>        [
>            "Africa/Asmara": DST(5, "bla")
>        ]
>    ;
> }
>
> Error: non-constant expression ["Africa/Asmara":(DST(5,"bla"))]

It's because AA initializers are not constants :P

AAs initializers are run at runtime, they cannot be stored in the static 
data segment so they cannot be constants.  You'll have to split it up:

public static DST[char[]] AA;

static this()
{
    AA = ["Africa/Asmara": DST(5, "bla")];
} 




More information about the Digitalmars-d-learn mailing list