Delphi Error – W1013 Constant 0 converted to NIL

Delphi Compiler Error

W1013 Constant 0 converted to NIL

Reason for the Error & Solution

The Delphi compiler now allows the constant 0 to be used in pointer expressions in place of NIL. This change was made to allow older code to still compile with changes which were made in the low-level RTL.

program Produce;

  procedure p0(p : Pointer);
  begin
  end;

begin
  p0(0);
end.

In this example, the procedure p0 is declared to take a Pointer parameter yet the constant 0 is passed. The compiler will perform the necessary conversions internally, changing 0 into NIL, so that the code will function properly.

program Solve;

  procedure p0(p : Pointer);
  begin
  end;

begin
  p0(NIL);
end.

There are two approaches to solving this problem. In the case above the constant 0 has been replaced with NIL. Alternatively the procedure definition could be changed so that the parameter type is of Integer type.

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