digitalmars.D.learn - anyone knows how to print __FUNCTION__ in D? and __LINE__
- davidl (4/4) Aug 14 2006 in c we can print __FUNCTION__ __LINE__ to indicate where we are. in D h...
- Oskar Linde (5/9) Aug 14 2006 __LINE__ works in D too. I'm not sure if __FUNCTION__ has much use in D,...
- Jarrett Billingsley (4/7) Aug 14 2006 In addition, you can find the list of all supported special tokens at
- BCS (9/12) Aug 14 2006 I use:
- renoX (4/16) Feb 23 2007 I disagree about the 'close' part: in C, you wrap __FILE__ or __LINE__ i...
- Bill Baxter (12/30) Feb 23 2007 You can use a mixin statement + new compile-time functions so that this
in c we can print __FUNCTION__ __LINE__ to indicate where we are. in D how to do, couldn't find..... -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Aug 14 2006
davidl wrote:in c we can print __FUNCTION__ __LINE__ to indicate where we are. in D how to do, couldn't find..... --使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/__LINE__ works in D too. I'm not sure if __FUNCTION__ has much use in D, as D lacks macros that could make use of it. (Evaluate it at the place of macro expansion). /Oskar
Aug 14 2006
"Oskar Linde" <oskar.lindeREM OVEgmail.com> wrote in message news:ebpvni$2l64$1 digitaldaemon.com...__LINE__ works in D too. I'm not sure if __FUNCTION__ has much use in D, as D lacks macros that could make use of it. (Evaluate it at the place of macro expansion).In addition, you can find the list of all supported special tokens at http://www.digitalmars.com/d/lex.html#specialtokens.
Aug 14 2006
davidl wrote:in c we can print __FUNCTION__ __LINE__ to indicate where we are. in D how to do, couldn't find.....I use: __FILE__":"~itoa!(__LINE__) writef(...) // at run time pragma(msg, ...)// at compile time Not quite as useful but close. BTW it requiters the itoa template that can be found about half way down this page: http://www.digitalmars.com/d/templates-revisited.html
Aug 14 2006
BCS Wrote:davidl wrote:I disagree about the 'close' part: in C, you wrap __FILE__ or __LINE__ in a macro, so you have the value of the call site, in D if you put them in a default argument or in a template you have the current value, not the call site which is nearly useless.. So let's not beat around the bush, this is an area where (AFAIK) C is superior to D.. renoXin c we can print __FUNCTION__ __LINE__ to indicate where we are. in D how to do, couldn't find.....I use: __FILE__":"~itoa!(__LINE__) writef(...) // at run time pragma(msg, ...)// at compile time Not quite as useful but close.
Feb 23 2007
renoX wrote:BCS Wrote:You can use a mixin statement + new compile-time functions so that this syntax is possible: mixin( Pr("Error!") ); Pr is a char[]function(char[]) that returns a string like: `writefln("%s(%s): %s", __FILE__, __LINE__, msg);` But of course in C you could define your macro so that you can say just Pr("Error!"), without needing the extra mixin( ... ) part. I think something. Then you could have $Pr("Error"); --bbdavidl wrote:I disagree about the 'close' part: in C, you wrap __FILE__ or __LINE__ in a macro, so you have the value of the call site, in D if you put them in a default argument or in a template you have the current value, not the call site which is nearly useless.. So let's not beat around the bush, this is an area where (AFAIK) C is superior to D.. renoXin c we can print __FUNCTION__ __LINE__ to indicate where we are. in D how to do, couldn't find.....I use: __FILE__":"~itoa!(__LINE__) writef(...) // at run time pragma(msg, ...)// at compile time Not quite as useful but close.
Feb 23 2007