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.

Christopher Chase
  • 2,728
  • 5
  • 34
  • 54
Scott W
  • 9,535
  • 2
  • 32
  • 51

5 Answers5

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.

JosephStyons
  • 53,646
  • 63
  • 151
  • 228
  • Doing a full build yields the exact same results as a Compile. – Scott W Jun 10 '09 at 20:51
  • What happens if you manually delete all the .DCU files, and then do a full build? – JosephStyons Jun 10 '09 at 20:52
  • Still the same result, I'm afraid. – Scott W Jun 10 '09 at 20:54
  • But if you close the IDE, then reopen it & do a full build... you get all the hints & warnings (the first time).. right? – JosephStyons Jun 10 '09 at 20:56
  • Try renaming your .DOF file to something else like MyProject.dof.OLD... let the IDE re-create it. What happens then? – JosephStyons Jun 10 '09 at 21:01
  • 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 Jun 10 '09 at 21:10
  • 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 Jun 10 '09 at 23:43
  • 7
    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 Jun 11 '09 at 00:29
  • 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. – user114285 Jun 11 '09 at 05:51
  • 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 Jun 11 '09 at 08:46
  • 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 Jun 11 '09 at 14:54
  • 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 Jun 15 '09 at 14:06
  • Try Ctrl+"O" twice to force-paste all the warnings in your code. Then do a build. What happens? – JosephStyons Jun 15 '09 at 15:46
  • 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 Jun 16 '09 at 15:58
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}

triip
  • 31
  • 1
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.

Francesca
  • 21,156
  • 3
  • 46
  • 87
  • 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 Jun 15 '09 at 14:21
  • We have had this problem with 3rd party code where the scope was not limited as expected. – Francesca Jun 15 '09 at 17:01
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.)

mjn
  • 35,561
  • 24
  • 160
  • 351
  • 1
    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 Jun 11 '09 at 04:18
  • 1
    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. – mjn Jun 11 '09 at 06:18
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.

Despatcher
  • 1,725
  • 12
  • 18