digitalmars.D.learn - AA within struct
- dominik (2/2) Feb 15 2008 what am I doing wrong here?
- Aarti_pl (10/15) Feb 15 2008 Struct initialization is different. Try this:
- dominik (16/22) Feb 15 2008 yeah I've tried that too:
- Jarrett Billingsley (10/21) Feb 15 2008 It's because AA initializers are not constants :P
- dominik (3/5) Feb 15 2008 thank you!
what am I doing wrong here? http://paste.dprogramming.com/dpjd03u4
Feb 15 2008
dominik pisze:what am I doing wrong here? http://paste.dprogramming.com/dpjd03u4Struct initialization is different. Try this: public static DST[char[]] AA = [ "Africa/Asmara"[]: {5, "bla"[]} ] ; BR Marcin Kuszczak (aarti_pl)
Feb 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"))]
Feb 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")];
}
Feb 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!
Feb 15 2008








"dominik" <aha aha.com>