Delphi Error – E2278 Cannot take address of local symbol %s

Delphi Compiler Error

E2278 Cannot take address of local symbol %s

Reason for the Error & Solution

This message occurs when you try to call a symbol from within a procedure or function that has been tagged with the local directive.

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

On Linux, the local directive is used for routines that are compiled into a library but are not exported. This 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 taken or be assigned to a procedural-type variable.
  • if it is a pure assembler routine, cannot be called from another unit unless the caller sets up EBX.