digitalmars.D.learn - is there any hack to determine if variable is __gshared?
- ketmar via Digitalmars-d-learn (19/19) Oct 13 2014 Hello.
- bearophile (4/6) Oct 13 2014 There is the -vtls compiler switch.
- ketmar via Digitalmars-d-learn (5/9) Oct 13 2014 On Mon, 13 Oct 2014 15:57:13 +0000
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) =3D !__traits(compiles, mixin("{auto a___ =3D 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.
Oct 13 2014
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
Oct 13 2014
On Mon, 13 Oct 2014 15:57:13 +0000 bearophile via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:let me quote myself: "i'm talking about CTFE". i need to build mixin string with this variables, to be precise.is there any hack/trick to determine if variable is __gshared?=20 or if it is a thread-local, for that matter?=20 There is the -vtls compiler switch.
Oct 13 2014