关于抽象类实例化的Delphi 2010编译器警告应该是编译器错误

han*_*aad 9 delphi compiler-errors compiler-warnings delphi-2010

当我实例化抽象类时,是否有任何编译器选项让编译器给我一个错误而不是一个警告?

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

var
    f : Foo;
begin
    f := Foo.Create;  // <-- should give me a compile time error
end;
Run Code Online (Sandbox Code Playgroud)

Del*_*ics 18

在Delphi 2010中(至少可能是早期版本但无法测试/验证):

Project -> Options

  + Delphi Compiler

     > Hints and Warnings

         + Output Warnings:

              Constructing instance containing abstract method:  ___________
Run Code Online (Sandbox Code Playgroud)

将此设置从" True " 更改为" Error "

  • 呃,`enum Boolean {True,False,Error}`,呃,我的大脑! (4认同)
  • @David Heffernan怎么说"曾经"?它是每个项目的编译时配置.真的是你的,明亮上尉. (2认同)