gpt4 book ai didi

德尔福XE6 DLL : Unwanted export: TMethodImplementationIntercept

转载 作者:行者123 更新时间:2023-12-03 14:39:04 24 4
gpt4 key购买 nike

当您在Delphi XE6中编译DLL时,它会自动从System.Rtti.pas导出函数TMethodImplementationIntercept。我试图找到一种方法来避免这种导出,但没有找到任何可以解决这个问题的配置或编译器指令。

System.Rtti 单元几乎是无法避免的,因为 Delphi 中的几乎所有内容都间接使用它。

在XE6中构建DLL时有没有办法避免导出这个函数?

最佳答案

System.Rtti 单元中的代码如下所示:

{ This function has been added to be used from .s .c files in order to avoid use mangled names}
procedure TMethodImplementationIntercept(const obj:TMethodImplementation; AFrame: Pointer); cdecl;
begin
obj.Intercept(AFrame);
end;
exports TMethodImplementationIntercept;

此函数和 exports 指令是在 XE5 中添加的。

Is there a way to avoid exporting this function when building a DLL in XE6?

如果您的库包含 System.Rtti 单元,则 DLL 将导出该函数。如果你想生成一个不导出函数的 DLL,我可以看到以下选项:

  1. 使用旧版本的 Delphi。
  2. 请勿在您的库中包含 System.Rtti
  3. 使用不导出函数的 System.Rtti 修改版本。
  4. 生成 DLL 后对其进行修改,以从 PE 导出表中删除该函数。

在我看来,前两个选项并不是很有吸引力。第三种选择似乎很有吸引力,但我认为它可能很难实现。看来这个长久以来的伎俩不再起作用了。我还无法重新编译 RTL 单元并避免可怕的 X was generated with a different version of Y 错误。

所以剩下最后的选择。再说一遍,吸引力不大。您很可能决定忍气吞声并接受这种杂散的导出。也许质量控制报告可能会给 Embarcadero 带来一点压力,要求其重新考虑这一决定。

无论如何,在我看来,任何编译器库代码都不应该无条件导出函数。做出决定的应该是库的使用者,而不是库的实现者。

关于德尔福XE6 DLL : Unwanted export: TMethodImplementationIntercept,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24718716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com