is there any hack to determine if variable is __gshared?
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 13 08:50:18 PDT 2014
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141013/01e03ebd/attachment.sig>
More information about the Digitalmars-d-learn
mailing list