Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

log class : get line number where function called

Hi , how can i write a macro to get the line number and function name when an error occured
thanks for ur help
[114 byte] By [dfom_2004] at [2007-11-11 8:06:39]
# 1 Re: log class : get line number where function called
Doesn't your compiler give these details already? Whe it encounters and error, the error message usually contains the line number and in some cases the code block/function name. Perhaps you need to explain better what is it that you're after.
Danny at 2007-11-11 21:01:36 >
# 2 Re: log class : get line number where function called
I'm going to guess that you are creating a macro that will allow you to write a message to a log file. Use the __LINE__ to capture the line number where the macro is expanded. Just a heads up you can get the current file name using __FILE__. These are ANSI compliant predefined macros.

Cheers,
Mike
marsigme at 2007-11-11 21:02:36 >
# 3 Re: log class : get line number where function called
the function's name can be obtained by using the __func__ or __FUNCTION__ name. However, this is less standardized so every vendor has its own symbol.
Danny at 2007-11-11 21:03:40 >