__FUNCTION__?

Nick Treleaven ntrel-public at yahoo.co.uk
Mon Feb 25 09:23:41 PST 2013


On 25/02/2013 16:32, js.mdnq wrote:
> We have __FILE__ and __LINE__. Is there a __FUNCTION__ that gives the
> current function name? This helps with errors.

You can define a string mixin to use instead of __FUNCTION__:

enum string parentName = q{__traits(identifier, __traits(parent, {}))};

void main()
{
     writeln(mixin(parentName)); // prints "main"
}



More information about the Digitalmars-d-learn mailing list