Delphi Error – E2070 Unknown directive – ‘%s’

Delphi Compiler Error

E2070 Unknown directive – ‘%s’

Reason for the Error & Solution

This error message appears when the compiler encounters an unknown directive in a procedure or function declaration.

The directive is probably misspelled, or a semicolon is missing.

program Produce;

procedure P; stcall;
begin
end;

procedure Q forward;

function GetLastError: Integer external 'kernel32.dll';

begin
end.

In the declaration of P, the calling convention “stdcall” is misspelled. In the declaration of Q and GetLastError, we’re missing a semicolon.

program Solve;

procedure P; stdcall;
begin
end;

procedure Q; forward;

function GetLastError: Integer; external 'kernel32.dll';

begin
end.

The solution is to make sure the directives are spelled correctly, and that the necessary semicolons are there.