How to force Delphi compiler to display all hints and warnings

萝らか妹 提交于 2019-12-10 02:24:54

问题


Is there a way to force the Delphi compiler to display all hints and warnings all the time?

Here is the behavior that I am currently seeing in Delphi 6:

  1. Check out fresh copy of my application from source control
  2. Open project in Delphi and Compile
  3. All hints and warnings for the project are displayed
  4. Make a change in one unit
  5. Compile
  6. Only the hints and warnings for the changed unit are displayed

So, I thought maybe I can trick Delphi by deleting all of the dcu files to force it to recompile everything. No luck. The compiler does in fact recompile all of the units, but does not display the hints and warnings for those units.

EDIT: Performing a full build (Project > Build) yields the same unfortunate results.

NEW INFORMATION: If I modify a unit and then Compile, I get the warnings. However, if I modify a unit and then Build, I do not get the warnings. I'm thinking this points to warnings being turned off somewhere. Possibly in a third party library?

It seems there ought to be a way to ask Delphi to re-display all of those hints and warnings that doesn't require me to either check out a fresh copy from source control or modify each unit one-by-one.


回答1:


I would check to see if you turn the warnings off in some of your units.
Depending on the last change in the units, the compiling order can change. In some cases the warnings can remain disabled for a unit that is compiled after while, when freshly checked out of version control, it was compiled before, with the warnings.
Pay extra attention to any Include file you may use.




回答2:


Hints and Warnings are generated by the compiler. It will only report on units that it has compiled. The "compile" command will only compile files that have changed. To force a recompilation of all units used by your project, use the Build command instead.

Later versions assign a shortcut key (Shift+F9) to the "Build" command.

To get that keyboard shortcut in Delphi 6, install this utility, which I've used for a while with great success on Delphi 5.




回答3:


I had the same problem and finally i found solution... Search for strings $WARNINGS OFF and $HINTS OFF, and not just from *.pas files but from all the files. I had this strange idea in third-party .inc file:

{$IFDEF DEBUG} {$WARNINGS ON} {$HINTS ON} {$ELSE} {$WARNINGS OFF} {$HINTS OFF} {$ENDIF}




回答4:


If you use dcc32.exe, all warnings will be shown, always. (This is another reason why I use build scripts for all my projects.)




回答5:


I am still using D6 for some projects and if I do a full build then all hints and warnings are displayed/re-displayed. For syntax check or compile only changed unit messages are displayed.

You have something else wrong or damaged somewhere. Try deleting the project .dsm and the .dof files (they will be rebuilt) the .dof file contains the warnings and hints flags.



来源:https://stackoverflow.com/questions/978040/how-to-force-delphi-compiler-to-display-all-hints-and-warnings

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