HomeDelphiDelphi Error – W1013 Constant 0 converted to NIL

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