local class instance (at module-level)

Andrea Fontana nospam at example.org
Thu Mar 14 11:15:01 UTC 2019


On Thursday, 14 March 2019 at 11:05:22 UTC, spir wrote:

> The most confusing error is:
> Error: variable `_base.c0` is a thread-local class and cannot 
> have a static initializer. Use `static this()` to initialize 
> instead.

Error is reffering to: 
https://dlang.org/spec/module.html#staticorder

You can do this:

C c0;

static this()
{
  c0 = new C();
}

Andrea


More information about the Digitalmars-d-learn mailing list