Global variables read at compile time?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 6 07:14:14 PDT 2014


On 05/06/2014 03:16 AM, Suliman wrote:

 > When I had create instance of class in main, and create confvarible
 > above it all worked, but when I had moved it's in module I got error.

There is module 'static this()' for such runtime initialization:

Config config;

static this()
{
     config = new Config(confname);
     if (config.isconfigexists())
         writeln("config exist");
     else
         writeln("config do not exists");
}

void main()
{}

Ali



More information about the Digitalmars-d-learn mailing list