Get name of current function
Stanislav Blinov via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Apr 23 13:38:15 PDT 2017
On Sunday, 23 April 2017 at 20:34:12 UTC, Mike B Johnson wrote:
> I'd like to get the symbolic name of the current function I'm in
>
> void foo()
> {
> writeln(thisFunc.stringof()); // prints foo
> }
>
> I need something short, elegant and doesn't require modifying
> preexisting code... I'm sure D has something along those lines?
__FUNCTION__ and __PRETTY_FUNCTION__
both will give qualified name though (e.g. module.foo), so, if
necessary, that has to be stripped out manually.
More information about the Digitalmars-d-learn
mailing list