问题
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