The "local" directive in Delphi

delphi

Solution

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.

Problem

I was sitting around debugging some code and I stumbled across this line in SysUtils.pas: ``` procedure ConvertError(ResString: PResStringRec); local; ``` What does the local keyword do exactly? It seems the ConvertError function is not declared in the interface section of the file, is this just a clarification that the function is indeed local, or is there a practical benefit to using this directive beyond that?

Original source