How To Get the Name of the Current Procedure/Function in Delphi (As a String)

后端 未结 6 1316
误落风尘
误落风尘 2020-12-29 03:47

Is it possible to obtain the name of the current procedure/function as a string, within a procedure/function? I suppose there would be some \"macro\" that is expanded at com

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 04:31

    I think you are doing it the wrong way round: First, check whether there is an error and only then (that is: You need the name of the caller) use some tool like JclDebug to get the name of the caller by passing the return address from the stack to it.

    Getting the procedure name is very expensive performance wise, so you only want to do it when absolutely necessary.

提交回复
热议问题