德尔福的“本地”指令

前端之家收集整理的这篇文章主要介绍了德尔福的“本地”指令前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在坐在调试一些代码,我在SysUtils.pas中偶然发现了这一行:
procedure ConvertError(ResString: PResStringRec); local;

本地关键字是做什么的?似乎ConvertError函数没有在文件的接口部分中声明,这仅仅是说明函数确实是本地的,还是使用这个指令以外的实际的好处?

解决方法

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

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.

06000

—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相关文章