January 27, 2020
Hello!
If I declare a static variable inside a struct that contains a shared field, is that new variable also shared? For example, say I have a custom atomic wrapper type, like C++'s std::atomic<T>, that contains only one shared variable: Does it remain shared when I instantiate one or do I have to rely on shared again (or __gshared)?
January 27, 2020
On 1/27/20 5:39 PM, Marcel wrote:
> Hello!
> If I declare a static variable inside a struct that contains a shared field, is that new variable also shared? For example, say I have a custom atomic wrapper type, like C++'s std::atomic<T>, that contains only one shared variable: Does it remain shared when I instantiate one or do I have to rely on shared again (or __gshared)?

I would say the type itself would have to be shared. You can (I think) declare shared types, which are automatically shared even without declaring the variable shared. At least, it used to be that way.

Note that anything you declare shared can be shared. So even if you can't share the enclosing struct, you can share the member.

-Steve