Is the trickery way that we can show the entire stack trace (function+line) for an exception, much like in Java and C#, in C++?
Can we do something with macros to accomplish that for windows and linux-like platforms?
thanks
Is the trickery way that we can show the entire stack trace (function+line) for an exception, much like in Java and C#, in C++?
Can we do something with macros to accomplish that for windows and linux-like platforms?
thanks
Not without either platform specific knowledge or addition of code in each function.
On Windows it can be done using the Windows DbgHelp API, but to get it exactly right requires lots of experimenting and twiddling. See http://msdn.microsoft.com/en-us/library/ms679267(VS.85).aspx for a start. I have no idea how to implement it for other platforms.
Hope this helps a bit.
Regards,
Sebastiaan
If you are running on a platform which uses glibc, you can use the backtrace() functions. This are C functions, but they do work for c++ back traces too. This is of course not portable, but I doubt you will find a portable solution without additional code in every function ;-)
http://www.gnu.org/software/libc/manual/html_node/Backtraces.html