0

Suppose that I tried to open a file but the file does not exist. I could check this with is_open() or catch an exception. But I would like to know in which function this action was attempted and on which line. If it is tricky to get line number, I am still OK with the function name. How can I do this?

Shibli
  • 5,879
  • 13
  • 62
  • 126

1 Answers1

1

C99 introduces __func__, and GCC has provided __FUNCTION__ for a long time. Both of these are strings containing the name of the current function.

source: https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html