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

前端 未结 5 1490
故里飘歌
故里飘歌 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 20:51

    I see from your example that you are using Qt. In which case your best bet is to use Q_FUNC_INFO found in . Here's the description:

    Expands to a string that describe the function the macro resides in. How this string looks more specifically is compiler dependent. With GNU GCC it is typically the function signature, while with other compilers it might be the line and column number.

提交回复
热议问题