链接器消除了Delphi 2009功能 [英] Delphi 2009 Function eliminated by linker

查看:94
本文介绍了链接器消除了Delphi 2009功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在调试项目时使用功能 DateTimeToStr 。我想使用评估/修改窗口或监视窗口。这总是会导致错误链接器消除了功能。

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.

推荐答案

我制作了以下程序

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.

这篇关于链接器消除了Delphi 2009功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆