Is there a DCC32 option to treat a specific compiler warning as an error?

孤人 提交于 2019-12-20 10:23:43

问题


For command-line builds, I would like to treat warnings (for example "Constructing instance containing abstract method") as errors. I have not found a dcc32 command line option for this purpose in Delphi 2009. Is there a way, for example using dcc32.cfg, to do this?


回答1:


Like this:

dcc32 -W^^CONSTRUCTING_ABSTRACT MyProject.dpr

For example, with this program:

program MyProject;

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

begin
  TMyClass.Create;
end.

And here's the output:

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

If you want all warnings to be treated as errors then you do it like this:

dcc32 -W^^ MyProject.dpr

For further reading I refer you to Delphi XE2's hidden hints and warnings options.



来源:https://stackoverflow.com/questions/15383471/is-there-a-dcc32-option-to-treat-a-specific-compiler-warning-as-an-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!