Initialising global associative array
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 6 13:39:13 PDT 2015
On Saturday, 6 June 2015 at 20:30:50 UTC, Paul wrote:
> However, I now get an 'undefined identifier' error when
> compiling and trying to access the AA from a function within
> the same module.
>
> static this()
> {
> string[string] tagWords = [ "DIST" : "Distance", .....
> }
>
> ...
>
> if(tag in tagWords)
> {
> retVal.tag = tagWords[tag]; <---- 'Error: undefined
> identifier tagWords'
> ...
You have to declare tagWords in module scope, but initialize it
in the static constructor:
string[string] tagWords;
static this()
{
tagWords = [ "DIST" : "Distance", .....
}
>
> According to Ali's book that looks like a linker message
Nope, that's not a linker message.
"undefined identifier" = compiler
"undefined reference" = linker
More information about the Digitalmars-d-learn
mailing list