static __gshared struct

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 1 20:54:26 PDT 2016


On Saturday, 2 July 2016 at 00:08:10 UTC, Hiemlick Hiemlicker 
wrote:

>
> I use a struct with static members so I do not have to 
> instantiate it. It is essentially a singleton. I want all the 
> variables to be __gshared. I guess I have to prefix all 
> variables with it?
>
> Basically I have Foo.i; on foo. i is static, of course. I also 
> want it to be __gshared.
>
> Makes sense to me that
>
> __gshared struct x;
>
> all of x's variables should be __gshared.

struct Foo {
    __gshared:
        static int x;
        static float y;
}

Or:

struct Foo {
    __gshared {
       static int x;
       static float y;
    }
}


More information about the Digitalmars-d-learn mailing list