Delphi Error – E2239 Default parameter ‘%s’ must be by-value or const

Delphi Compiler Error

E2239 Default parameter ‘%s’ must be by-value or const

Reason for the Error & Solution

Parameters which are given default values cannot be passed by reference.

program Produce;

  procedure p0(var x : Integer = 151);
  begin
  end;

begin
end.

Since the parameter x is passed by reference in this example, it cannot be given a default value.

program Solve;

  procedure p0(const x : Integer = 151);
  begin
  end;

begin
end.

In this solution, the by-reference parameter has been changed into a const parameter. Alternatively it could have been changed into a by-value parameter or the default value could have been removed.

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...