__traits(moduleName)?
Nick Sabalausky
a at a.a
Wed Sep 8 02:04:43 PDT 2010
"Nick Sabalausky" <a at a.a> wrote in message
news:i67for$gr1$1 at digitalmars.com...
> Is there some way, maybe with __traits, to get the name of the current
> module?
I don't know if there's an easier/better way, but this seems to work:
module someModuleName;
import std.demangle;
import std.stdio;
import std.traits;
private int _getModuleName_dummy_;
void main()
{
auto moduleName =
demangle( mangledName!_getModuleName_dummy_ )
["int ".length .. $-1-_getModuleName_dummy_.stringof.length];
writeln(moduleName);
}
More information about the Digitalmars-d-learn
mailing list