How to force Delphi compiler to display all hints and warnings
Asked Answered
S

6

9

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.

Spelt answered 10/6, 2009 at 20:43 Comment(1)
Delphi 1 or Delphi 2009, or something inbetween? It would be helpful to know...Booty
S
3

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.

Saliva answered 11/6, 2009 at 18:5 Comment(2)
I am not explicitly including any files (beyond uses statements) and my interpretation of the help files on the $WARN and $WARNINGS directives is that they do not apply beyond the scope of the current unit. In any case, I haven't got any of those directives in my code. Could a used unit from a third party library cause the problem?Spelt
We have had this problem with 3rd party code where the scope was not limited as expected.Saliva
S
7

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.

Scheller answered 10/6, 2009 at 20:46 Comment(14)
Doing a full build yields the exact same results as a Compile.Spelt
What happens if you manually delete all the .DCU files, and then do a full build?Scheller
Still the same result, I'm afraid.Spelt
But if you close the IDE, then reopen it & do a full build... you get all the hints & warnings (the first time).. right?Scheller
Try renaming your .DOF file to something else like MyProject.dof.OLD... let the IDE re-create it. What happens then?Scheller
Sorry, closing IDE, deleting all DCU and then reopen: same result; Letting the IDE re-create the DOF file: same result; Letting the IDE re-create the DRC and RES files: same resultSpelt
This is very strange, then. A full build ought to generate all hints and warnings. Sounds like you've got a glitch. (Delphi 6 had a fair number of them, so I'm not surprised.)Pylon
Doing a full build should definitely /not/ return the same results as a second compile. I suspect you aren't compiling the code you think you are compiling. I'd check your paths to make absolutely sure that the code you think you are compiling is indeed getting compiled.Mozarab
Deleting the dcu's should get all the units to be recompiled by the linker. This is rather strange. For my experience the IDE tracks the changes in code and compiles only the changed units. If a unit has no compiled file under project search the path(s) it should be compiled. So when you delete all the DCUs you're rebuilding all.Petronius
I too have the same experience: Doing a full build of the project, does definitely not show all the warnings in all units. It has been like this at least in Delphi 2006 and 2007. Apart from the RTL everything is compiled from source, so the only dcus are in the RTL search path and the dcu output path (which is not the same as the source path).Requital
How about this... try renaming one of the SOURCE files that you think you are compiling... Does that cause the compile to fail? How about the build? It should... but if it does not, then you are compiling something else.Scheller
Yep renaming a source file (specifically one that has warnings that should be showing up) causes both the compile and the build to fail with "File not found" errors.Spelt
Try Ctrl+"O" twice to force-paste all the warnings in your code. Then do a build. What happens?Scheller
CTRL+O, CTRL+O didn't help. But adding {$WARNINGS ON} to the top of one of the units that has warnings did. So now all I have to do is figure out which of my third party components is misbehaving since I don't use the {$WARNINGS} directive anywhere in my own code. Thanks for all of your help.Spelt
B
4

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}

Buss answered 27/7, 2010 at 13:53 Comment(1)
I would try to avoid any future components from anyone who did something like this.Thistledown
S
3

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.

Saliva answered 11/6, 2009 at 18:5 Comment(2)
I am not explicitly including any files (beyond uses statements) and my interpretation of the help files on the $WARN and $WARNINGS directives is that they do not apply beyond the scope of the current unit. In any case, I haven't got any of those directives in my code. Could a used unit from a third party library cause the problem?Spelt
We have had this problem with 3rd party code where the scope was not limited as expected.Saliva
L
2

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

Letishaletitia answered 10/6, 2009 at 22:10 Comment(2)
That is not completely true, only when the -B switch is given to dcc32, which is the equivalent of doing a full build in the IDE. Without that switch dcc32 defaults to doing incremental builds too. And warnings will be shown only for units that get compiled, obviously.Thomasenathomasin
You are right, -B is required. For some projects I start with copying the sources to a empty target directory structure, only in this case a -B is not necessary.Letishaletitia
P
0

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.

Petty answered 11/6, 2009 at 12:12 Comment(1)
No luck with having the DOF regenerated. I cannot find any .dsm file in my project.Spelt
S
0

I managed to get rid of all hints and warnings in my project and was wondering why the "Build" tab was not displaying any information. So I declared an unused variable and got one - just so I could see it.

Scurrilous answered 21/3, 2023 at 4:44 Comment(1)
This is not an answer, should be a comment insteadWanids

© 2022 - 2024 — McMap. All rights reserved.