In Delphi, you can use compiler directives to disable specific warnings, such as
{$WARN USE_BEFORE_DEF OFF}
But when I tried to do that with a specific hint, whose underscore_style_name I got out of the helpfile, the compiler said it doesn't know what {$HINT} is. So is there any way to do this?
Best I can think of is to surround the subject of the hint with a conditional define, and use the same conditional define around the code that may or may not be needed, as shown below:
If you have this:
You will get: Hint: variable "i" is declared but never used
So try this instead:
Now you can turn the define on or off, and you should never get a hint.
No specific hints, but you can disable them all.
Little off-topic: You should take care about compiler's hints and warnings. They are not just for fun. Compiler is just saying "program may work differently that you think because YOUR source code is not exact".
To play it really safe, one would like to do something like this:
Unfortunately there seems to be no compiler directive for checking whether hints are off or not, so you can't do this. (H+ is not for hints but for long strings). Also, HINTS OFF / ON does not work within a function/procedure.
So you end up turning hints off and on unconditionally for the whole function:
(The compiler used to tell me that it could not inline dzDGetText which is something I don't care about in this case and I don't want to see the hint because this would stop me (and my coworkers) to care about important hints.)