gpt4 book ai didi

delphi - Delphi中的 "local"指令

转载 作者:行者123 更新时间:2023-12-03 14:34:42 25 4
gpt4 key购买 nike

我正在调试一些代码,我在 SysUtils.pas 中偶然发现了这一行:

procedure ConvertError(ResString: PResStringRec); local;

local 关键字到底有什么作用?似乎 ConvertError 函数没有在文件的接口(interface)部分中声明,这只是澄清该函数确实是本地函数,还是除此之外使用此指令还有实际好处?

最佳答案

它可以追溯到 Linux 编译器 Kylix。以下是我在 Delphi 6 语言指南第 9-4 页中看到的内容:

The directive local, which marks routines as unavailable for export, is platform-specific and has no effect in Windows programming.

On Linux, the local directive provides a slight performance optimization for routines that are compiled into a library, but are not exported. The directive can be specified for standalone procedures and functions, but not for methods. A routine declared with local—for example.

function Contraband(I: Integer): Integer; local;

—does not refresh the EBX register and hence

  • cannot be exported from a library.
  • cannot be declared in the interface section of a unit.
  • cannot have its address take or be assigned to a procedural-type variable.
  • if it is a pure assembler routine, cannot be called from a another unit unless the caller sets up EBX.

关于delphi - Delphi中的 "local"指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15764719/

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