RAD Studio (Common)
ContentsIndex
PreviousUpNext
H2219: Private symbol '%s' declared but never used (Delphi)

The symbol referenced appears in a private section of a class, but is never used by the class. It would be more memory efficient if you removed the unused private field from your class definition.

program Produce;
  type
    Base = class
    private
      FVar : Integer;
      procedure Init;
    end;

procedure Base.Init;
begin
end;

begin
end.

Here we have declared a private variable which is never used. The message will be emitted for this case.

program Solve;
program Produce;
  type
    Base = class
    private
      FVar : Integer;
      procedure Init;
    end;

procedure Base.Init;
begin
  FVar := 0;
end;

begin
end.

There are various solutions to this problem, and since this message is not an error message, all are correct. If you have included the private field for some future use, it would be valid to ignore the message. Or, if the variable is truly superfluous, it can be safely removed. Finally, it might have been a programming oversight not to use the variable at all; in this case, simply add the code you forgot to implement.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!