How to disconnect warnings from this unit without changing this device?

So, I include some other units in my block, and after creating the application, I get a huge amount of warnings from these units. The amount is so large that I have problems finding my own alerts on the list .; -)

Is there any compiler directive that would allow me to disable these warnings? But keep in mind that I do not want to modify these devices 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. 

Is this an imaginary compiler directive that I would like to have, or maybe it exists, and I don’t know about it?

Thank you for your time.

+4
source share
3 answers

There is a compiler directive to disable warnings, but this can only be set in the project parameters, in which case this applies to all units or the block itself, and in this case it applies only to this unit.

So, you have a few options left.

An unrealistic option that does exactly what you ask for:

Thus, the only solution would be to disable warnings in your project, and then enable them in all of your own departments using this directive.

The simplest and most realistic option:

Compile the units once and use only the DCU, removing the source from your library path. This is easiest if you do not want to edit them.

You can add them to your viewing path, which is different from the library path. DCUs are used in this case, but Delphi can still find the sources, so you can navigate through them during debugging.

A small advantage is that the creation of your project is faster, because these units do not need to be recompiled in each assembly.

The best way:

Stop using these devices at all. Units with so many warnings are poor software and can cause serious problems.

Other solutions:

  • Postpone your wishes not to change the modules and add all the compiler directives to them.
  • Resolve warnings
+7
source

No, I do not believe that such a directive exists.

The only way I found for this is

  • compile everything
  • put the offending block dcu somewhere where the compiler finds it
  • make sure dcu is detected BEFORE the source source for dcu or make sure the source is not found by the compiler

This ensures that pas is not compiled, so you will not be clogged with warnings from intruders.

This is the approach that I often take with library units (which we always compile from the source) when I do not want the debugger to go into them. I compile the release configuration (debug = off) and then pick up the dcu units that I don't want to enter, and make sure that they are found by the compiler before their respective pas files.

One caveat: make sure that when you (need) to work on abusive devices, dcu is deleted, or you will run into a lot of confusion. This can help GExperts' Clean Directories.

+2
source

I am using Delphi 7 and here is how I do it ...

Do not include it in the .dpr project, or it will not work, add the device folder to the search path of the project settings.

Then, in each module that you use, use the following compiler directives:

  uses {$WARNINGS OFF}{$HINTS OFF} TheUnitHere; {$WARNINGS ON}{$HINTS ON} 
0
source

All Articles