I'm trying to perform some analysis of an existing program and need to log line numbers without modifying the program too much. I've been playing with __LINE__ and was hoping to do something like this:
file.h:
void Function( int iLine = __LINE___ ); // original function had no arguments, but now overloaded to default __LINE__
file.cpp:
void Function( int iLine ) { // original function had no arguments, but now changed to int iLine
// do something here
// log iLine number to a file for analysis
}
main.cpp call:
Function(); // call existing function
However, I now know this is not going to work as iLine is always the file.h definition line number.
I've tried StackWalker, but also had difficulty and seemed a little overkill.
Any suggestions on how to approach this while keeping original file changes minimal?