在Delphi中可以在运行时获取源行号吗?我知道JCL调试,但我想避免使用它.Assert也不是我想要的.我想得到这样的东西,GetLineNumber将得到源代码行.是否可以在没有MAP文件的情况下执行此操作(无论如何,当我使用Assert时会生成MAP文件)?有什么例子吗?
function GetLineNumber: integer;
begin
???
end;
procedure ThisWouldBeGreat;
begin
if not SomeCondition then
LogMemo.Lines.Add('Error on line: ' + IntToStr(GetLineNumber));
end;
procedure ThatsWhatIWont;
begin
Assert(not SomeCondition, 'Error');
end;
Run Code Online (Sandbox Code Playgroud)
谢谢