How to enable specific Delphi warnings and tips?

In CodeGear Delphi 2007, how can I turn off specific warnings and tips? I am trying to disable H2077 - the value assigned to "varname" has never been used.

+4
source share
5 answers

Tips? No specific .

You will have to disable them all:

{$HINTS OFF} 

Warnings?

 {$WARN _name_of_warning_ OFF|ON|ERROR} 

Find a complete list here.

+13
source

You cannot disable certain hints as you can with warnings. Hints are those things that will not have any potential negative consequences for your code at runtime. For example, when you see the prompt “The value assigned to“ varname has never been used, ”this is just an assumption that you should probably“ clear ”in your code, but that will not cause any potential runtime errors ( besides your own logical errors, of course :-). Hints are always best solved by customizing the code.

Warnings, on the other hand, are those things that can lead to unforeseen runtime behavior and indeed . For example, using a variable before assigning it a value is clearly an example of an uninitialized variable, which can lead to "bad things." In the vast majority of cases, warnings should be resolved by “fixing” the code. Even then, under certain circumstances, you may consider the warning “false positive” and you are sure that the code is functioning correctly. In such cases, you can disable a specific warning. Disabling all alerts is dangerous.

+17
source

Why don't you change the code instead so that the tooltip disappears? These hints are usually pretty accurate. And if you really feel that a line of code (I assume that initializing a variable or another) is useful to the reader of your code, even if it is not related to the compiler, you can replace it with a comment.

+9
source

What did Lars say. In addition, you can get a complete list of alerts and their current settings by pressing CTRL-O twice. It will list at the top of the current block. You can look there to find the one you need to change. Just remember to delete the list later, otherwise people who look at the code later will hate you.;)

+4
source

To remove a tooltip for a line of code that has:

H2077 Value assigned to '% s' has never been used

You can wrap it:

 {$HINTS OFF} //... {$HINTS ON} 

For example, from the buggy Vcl.ComCtrls.pas :

 procedure TTrackBarStyleHook.Paint(Canvas: TCanvas); //.... begin if not StyleServices.Available then Exit; {$HINTS OFF} Thumb := ttbTrackBarDontCare; //value assigned to 'Thumb' never used {$HINTS ON} //... end; 

Note Any code released to the public domain. No attribution required.

+3
source

All Articles