Delphi Error – E2191 EXPORTS allowed only at global scope

Delphi Compiler Error

E2191 EXPORTS allowed only at global scope

Reason for the Error & Solution

An EXPORTS clause has been encountered in the program source at a non-global scope.

program Produce;

  procedure ExportedProcedure;
  exports ExportedProcedure;
  begin
  end;

begin
end.

It is not allowed to have an EXPORTS clause anywhere but a global scope.

program Solve;

  procedure ExportedProcedure;
  begin
  end;

exports ExportedProcedure;
begin
end.

The solution is to ensure that your EXPORTS clause is at a global scope and textually follows all procedures named in the clause. As a general rule, EXPORTS clauses are best placed right before the source file’s initialization code.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...