| Thread overview | |||||
|---|---|---|---|---|---|
|
October 13, 2014 is there any hack to determine if variable is __gshared? | ||||
|---|---|---|---|---|
| ||||
Attachments: | Hello.
i need to enumerate all module variables of the given types (it's easy, this is not the question) and make list of only __gshared ones. of course, i'm talking about CTFE.
is there any hack/trick to determine if variable is __gshared? or if it is a thread-local, for that matter?
i added 'isGShared' trait to my compiler, but i'm not expecting from others to do the same. ;-)
the only hack i invented is this abomination:
int v0;
__gshared int v1;
enum isGShared(alias var) =
!__traits(compiles,
mixin("{auto a___ = function typeof("~var.stringof~
") () @safe { return "~var.stringof~"; };}"));
pragma(msg, isGShared!v0); // false
pragma(msg, isGShared!v1); // true
sure, it's very limited, and we must do alot of checks before using it. it *SEEMS* to work, but i not tested it very well.
| |||
October 13, 2014 Re: is there any hack to determine if variable is __gshared? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ketmar | ketmar:
> is there any hack/trick to determine if variable is __gshared? or if it is a thread-local, for that matter?
There is the -vtls compiler switch.
Bye,
bearophile
| |||
October 13, 2014 Re: is there any hack to determine if variable is __gshared? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile Attachments: | On Mon, 13 Oct 2014 15:57:13 +0000 bearophile via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > > is there any hack/trick to determine if variable is __gshared? or if it is a thread-local, for that matter? > > There is the -vtls compiler switch. let me quote myself: "i'm talking about CTFE". i need to build mixin string with this variables, to be precise. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply