On Mon, 07 Sep 2009 12:41:46 -0400, Byron Heads <[email protected]>
wrote:
I've looked through the lex documents but there seems to be no special
token
to get the current calling function.
In c you can use the __func__ token to get the current function.
I thinking adding __FUNCTION__ would be useful for things like logging.
Also is there a nice way to replace logging macros? I often have a
logger
that looks like
logmsg( int level, uint line, char* func, char* file, char[] msg, ... );
then I would write some macros like:
#define LOGDEBUG( m, ... ) logmsg( LVL_DEBUG, __LINE__, __func__,
__FILE__, msg, __VA_ARGS__ )
thus i would only have to do
LOGDEBUG( "SOME STRING with formatting", formatting args.. )
-B
You can put __LINE__, etc into template parameters. For example:
void echo(int T = __LINE__, U...)(U msg) { writeln(T,": ",msg); }