English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

This answer is for the GNU/Linux system that I am using. I am not sure of other OS's.
You can get the name of the .c file from a.out provided you compiled it using the -g option using gcc.You can do an objdump on the a.out to show the file names of the .c files used.
I use objdump -lDf for getting the line numbers and the file names while debugging the symbols of a core dump.

2006-06-27 18:32:27 · answer #1 · answered by Capt. Nemo 3 · 0 0

Not sure if this is what you are asking but try something like this

printf("%s %s %s\n", __FILE__, __FUNCTION__, __LINE___);

Those three constants are defined by the compiler (gcc any way) and can be used to extract the current file name, function name, and line number of that line of code. Very useful for debugging.

2006-06-28 12:40:55 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers