Delphi 2009 Function eliminated by linker

隐身守侯 提交于 2019-12-07 11:58:30

问题


I want to use the function DateTimeToStr while debugging a project. I want to use either the evaluate/modify window, or the watch window. This always results in the error "Function eliminated by linker".

I've ensured that the function is used by the project (I also placed a call explicitly in the function I want to debug), also I turned off the optimization and recompiled the whole project.


回答1:


I made the following program

program WhereDidItGo;
{$APPTYPE CONSOLE}
uses
  SysUtils;

begin
  DateTimeToStr(0.0);
end.

And found exactly what you report. The evaluate/modify window reports that the function was eliminated. Weird.

Anyway, I tried this, which seemed to be enough to trick it.

program WhyDoesThisSolveTheOddity;
{$APPTYPE CONSOLE}
uses
  SysUtils;

var
  FunctionPtr: function(const DateTime: TDateTime): string;
  VarFalse: Boolean;

begin
  if VarFalse then
    FunctionPtr := @DateTimeToStr;
end.

Perhaps the issue is that the function is declared as being inline. Although in my tests, the function call was not actually being inlined.



来源:https://stackoverflow.com/questions/12748105/delphi-2009-function-eliminated-by-linker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!