Delphi – E2070 Unknown directive – ‘%s’

When the delphi compiler detects an unfamiliar directive in a procedure or function declaration, this error message displays.

It’s likely that the directive is misspelt or that a semicolon is missing.

program Produce;

procedure P; stcall;
begin
end;

procedure Q forward;

function GetLastError: Integer external 'kernel32.dll';

begin
end.

The calling convention “stdcall” is misspelt in P’s declaration. A semicolon is missing from the Q and GetLastError declarations.

program Solve;

procedure P; stdcall;
begin
end;

procedure Q; forward;

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

begin
end.

The answer is to double-check that the directives are correctly worded and that the required semicolons are there.