__FUNC__ in D

argl me at somewhere.com
Wed Aug 15 10:33:41 PDT 2007


Sorry, stupid me forgot the declaration. I am still getting an error though.

dmd -J/tmp test3.d
test3.d(7): Error: cannot evaluate GetLastFnDef("import tango.io.Stdout;\x0a\x0achar[] GetLastFnDef(char[] file, int line);\x0a\x0avoid main()\x0a{\x0a    const char[] fn = GetLastFnDef(import(__FILE__), __LINE__);\x0a    Stdout (\"hello {}\", fn).newline;\x0a}\x0a\x0a\x0a\x0a\x0a",7) at compile time

Any help would be appreciated.

argl Wrote:

> That would be wonderful! 
> I am getting the following errors though.
> Where do I find GetLastFnDef() ?
> 
> dmd -Jpath -run ./test.d
> test.d(80): Error: undefined identifier GetLastFnDef
> test.d(80): Error: need -Jpath switch to import text file test.d
> test.d(80): Error: function expected before (), not GetLastFnDef of type int
> test.d(80): Error: cannot implicitly convert expression (GetLastFnDef("",80L)) of type int to char[]
> 
> 
> BCS Wrote:
> 
> > Reply to Jarrett,
> > 
> > > "argl" <cavenhaus at gmail.com> wrote in message
> > > news:f9qrup$nqe$1 at digitalmars.com...
> > > 
> > >> Hi, I know this has come aup a few times in the past, but I have not
> > >> come across a clear answer.
> > >> 
> > >> Is it possible in any way to get the name of the current function for
> > >> logging purposes? Something to get the functionality of __FUNC__ in
> > >> C?
> > >> 
> > > No.
> > > 
> > 
> > CTFE anyone?
> > 
> > char[] GetLastFnDef(char[] file, int line);
> > 
> > use like this:
> > 
> > const char[] fn = GetLastFnDef(import(__FILE__), __LINE__);
> > 
> > 
> 



More information about the Digitalmars-d-learn mailing list