views:

659

answers:

5

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.

+6  A: 

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.

JosephStyons
Doing a full build yields the exact same results as a Compile.
Scott W
What happens if you manually delete all the .DCU files, and then do a full build?
JosephStyons
Still the same result, I'm afraid.
Scott W
JosephStyons
Try renaming your .DOF file to something else like MyProject.dof.OLD... let the IDE re-create it. What happens then?
JosephStyons
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 result
Scott W
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.)
Mason Wheeler
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.
Nick Hodges
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.
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).
dummzeuch
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.
JosephStyons
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.
Scott W
Try Ctrl+"O" twice to force-paste all the warnings in your code. Then do a build. What happens?
JosephStyons
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.
Scott W
+1  A: 

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

mjustin
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.
mghie
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.
mjustin
A: 

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.

Despatcher
No luck with having the DOF regenerated. I cannot find any .dsm file in my project.
Scott W
+1  A: 

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.

François
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?
Scott W
We have had this problem with 3rd party code where the scope was not limited as expected.
François
+1  A: 

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}

triip
I would try to avoid any future components from anyone who did something like this.
Loren Pechtel