How to find the name of the current function at runtime?

后端 未结 7 794
走了就别回头了
走了就别回头了 2021-01-31 15:17

After years of using the big ugly MFC ASSERT macro, I have finally decided to ditch it and create the ultimate ASSERT macro.

I am fine with getting the file and line num

7条回答
  •  梦如初夏
    2021-01-31 15:51

    you can easily use func. it will take back you current function name at runtime which raised the exception.

    usage:

    cout << __func__ << ": " << e.what();
    

提交回复
热议问题