Get name of current function

Mike Wey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 23 13:37:14 PDT 2017


On 04/23/2017 10:34 PM, 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?

The __FUNCTION__ keyword would give you the fully qualified name of the 
function.

http://dlang.org/spec/traits.html#specialkeywords

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list