Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
February 15, 2008 AA within struct | ||||
---|---|---|---|---|
| ||||
what am I doing wrong here? http://paste.dprogramming.com/dpjd03u4 |
February 15, 2008 Re: AA within struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dominik | 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 Re: AA within struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Aarti_pl | "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 Re: AA within struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dominik | "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 Re: AA within struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | "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! |
Copyright © 1999-2021 by the D Language Foundation