Thread overview
AA within struct
Feb 15, 2008
dominik
Feb 15, 2008
Aarti_pl
Feb 15, 2008
dominik
Feb 15, 2008
dominik
February 15, 2008
what am I doing wrong here?

http://paste.dprogramming.com/dpjd03u4


February 15, 2008
dominik pisze:
> what am I doing wrong here?
> 
> http://paste.dprogramming.com/dpjd03u4 
> 
> 


Struct initialization is different. Try this:

public static DST[char[]] AA =
        [
            "Africa/Asmara"[]: {5, "bla"[]}
        ]
    ;

BR
Marcin Kuszczak
(aarti_pl)
February 15, 2008
"Aarti_pl" <aarti@interia.pl> wrote in message news:fp3rpc$rm5$1@digitalmars.com...
> Struct initialization is different. Try this:
>
> public static DST[char[]] AA =
>         [
>             "Africa/Asmara"[]: {5, "bla"[]}
>         ]
>     ;

yeah I've tried that too:
Error: not an associative array initializer

I have also tried this:
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"))]


February 15, 2008
"dominik" <aha@aha.com> wrote in message news:fp3s4m$srr$1@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")];
}


February 15, 2008
"Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:fp46ir$1p3l$1@digitalmars.com...
> 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:

thank you!