Search code examples
delphicompiler-errorsdelphi-2010compiler-warnings

Delphi 2010 compiler warning about instantiation of abstract class should be a compiler error


Is there any compiler options that let the compiler give me an error instead of a warning when i instantiate an abstract class?

Foo = class
    procedure Bar; virtual; abstract;
end;

var
    f : Foo;
begin
    f := Foo.Create;  // <-- should give me a compile time error
end;

Solution

  • In Delphi 2010 (at least, possibly earlier versions but cannot test/verify):

    Project -> Options
    
      + Delphi Compiler
    
         > Hints and Warnings
    
             + Output Warnings:
    
                  Constructing instance containing abstract method:  ___________
    

    Change this setting from "True" to "Error"