是否有DCC32选项将特定编译器警告视为错误?

时间:2013-03-13 11:03:50

标签: delphi compiler-warnings

对于命令行构建,我想将警告(例如“构造包含抽象方法的实例”)视为错误。我在Delphi 2009中没有为此目的找到dcc32命令行选项。有没有办法,例如使用dcc32.cfg来执行此操作?

1 个答案:

答案 0 :(得分:10)

像这样:

dcc32 -W^^CONSTRUCTING_ABSTRACT MyProject.dpr

例如,使用此程序:

program MyProject;

type
  TMyClass = class
    procedure X; virtual; abstract;
  end;

begin
  TMyClass.Create;
end.

这是输出:

>dcc32 MyProject.dpr
Embarcadero Delphi for Win32 compiler version 24.0
Copyright (c) 1983,2012 Embarcadero Technologies, Inc.
Myproject.dpr(9) Warning: W1020 Constructing instance of 'TMyClass' containing abstract method 'TMyClass.X'
Myproject.dpr(12)
13 lines, 0.03 seconds, 21568 bytes code, 13256 bytes data.

>dcc32 -W^^CONSTRUCTING_ABSTRACT MyProject.dpr
Embarcadero Delphi for Win32 compiler version 24.0
Copyright (c) 1983,2012 Embarcadero Technologies, Inc.
Myproject.dpr(9) Error: E1020 Constructing instance of 'TMyClass' containing abstract method 'TMyClass.X'
Myproject.dpr(12)

如果您希望将所有警告视为错误,那么您可以这样做:

dcc32 -W^^ MyProject.dpr

如需进一步阅读,请转介Delphi XE2's hidden hints and warnings options