The “local” directive in Delphi

后端 未结 1 1899
没有蜡笔的小新
没有蜡笔的小新 2021-02-12 14:38

I was sitting around debugging some code and I stumbled across this line in SysUtils.pas:

procedure ConvertError(ResString: PResStringRec); local;
1条回答
  •  一整个雨季
    2021-02-12 15:02

    It dates back to the Linux compiler, Kylix. Here's what I can see in my Delphi 6 language guide, page 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.

    0 讨论(0)
提交回复
热议问题