Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable warnings from given unit without modifying that unit?

So I am including in my unit some other units and after building application I receive a huge amount of warnings from those units. The amount is so large that I'am having problems in finding my own warnings on the list. ;-)

Is there some compiler directive which would allow me to turn those warnings off? But please note, that I don't want to modify those units in any way. I would like to achieve something like this:

unit MyUnit;

interface

uses
  UnitA, {$WARN EMIT_WARNNIGS OFF} UnitB, {$WARN EMIT_WARNNIGS ON} UnitC, UnitD.

implementation

uses
  UnitE, {$WARN EMIT_WARNNIGS OFF} UnitF, UnitG, {$WARN EMIT_WARNNIGS ON} UnitH.

This is an imaginary compiler directive which I would like to have, or maybe it exists and I don't know about it?

Thanks for your time.

like image 885
Wodzu Avatar asked Jul 04 '11 14:07

Wodzu


1 Answers

There is a compiler directive to turn warnings off, but this can only be set in either project options in which case it applies to all units, or in a unit itself in which case it applies to that unit alone.

So, you're left with a few options.

Unrealistic option that does exactly what you ask:

So the only solution would be to disable warnings in your project and then enable them in all your own units using that directive.

Easiest and most realistic option:

Compile the units once and only use the DCUs by removing the source from your library path. That's easiest if you do not want to edit them anyway.

You can still add them in your browsing path which is different from the library path. In that case, the DCUs are used, but Delphi can still find the sources, so you can still navigate them whilst debugging.

Small advantage is that building your project is faster too, because these units don't need to be recompiled on each build.

Best option:

Stop using those units at all. Units with so many warnings are inferior software and can cause serious problems.

Other solutions:

  • Set aside your wishes of not modifying the units and add the compiler directives to those units anyway
  • Solve the warnings
like image 95
GolezTrol Avatar answered Sep 20 '22 08:09

GolezTrol