How to get the function name while in a function for debug strings?

前端 未结 5 1480
故里飘歌
故里飘歌 2021-02-01 20:35

I want to output the function name each time it is called, I can easily copy and paste the function name, however I wondered if there was a shortcut that would do the job for me

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 21:00

    If you check out boost there is a macro BOOST_CURRENT_FUNCTION that is portable across platforms. In the C99 standard there is a compiler variable __func__ that has the desired effect. I believe has been accepted into the C++0x standard. A reasonable number of compilers will already support this.

提交回复
热议问题