Hi, does anyone of you know a way to get the name of the current module at compile-time?
I have a very fragile trick, creating a temporary, mangling/demangling it and parsing the resulting name, but it's ugly as hell and does not work so well. I need this for a very simple reason: I have a huge string mixin which introduces helper structs in the current scope. The user may well use the mixin many time with common arguments, which will mix-in many times the same structs. So, botch. Say I have: mixin("struct Foo {}"); //... mixin("struct Foo {}"); My first thought was to insert a static this: mixin("static if (!is(Foo)) struct Foo {}"); But this does not work :-( after the first mixin the code is not compiled yet, so Foo is not a type. But I discovered that __traits(allMembers, currentModule) _will_ contain "Foo" after the first mixin. So I can test for the existence of Foo this way and abort creating it a second time. But, for that to work, I need the (local!) module name at compile-time, the one the string will be mixed in. Philippe