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 X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...