I have three files foo1, foo2, and foo3.
foo2 and foo3 call a function in foo1.
I am trying to have foo1 detect the file name and line number of the caller without passing those as parameters in the function.
How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When running a native program, the concept of files and lines doesn’t hold ground any more. The program is just a stream of commands to the processor – the names of the functions, variables, the line numbers, the file names, all is lost during compilation.
Extracting debugging information from a program is virtually impossible. That program would have to be specifically compiled to have the debugging information attached. Sometimes (like the Visual C++), the debugging info is extracted into a separate file – but you would need that file and know its format, to extract that info. And you would be getting only the debug info. Not the compiled code.
The parameters are the way to go.