1

For Delphi compiler directives, is there a way to turn a switch directive to its "current global default state"?

I have read the documentation page at http://docwiki.embarcadero.com/RADStudio/Sydney/en/Delphi_compiler_directives, but it explains only how to turn switch directives on or off. My code contains several places with this construct (meant to avoid hints for a particular section of code):

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

However, this turns hints (back) on afterwards, which is not what I want when I do e.g. a release compilation with hints suppressed globally (using for example the -H- option to the dcc32.exe command-line compiler).

I would want something like this:

{$HINTS OFF}
  // ... some code ...
{$HINTS DEFAULT}

Does that exist?

Matthias B
  • 404
  • 4
  • 11
  • 2
    Unfortunately, most of the [compiler directives](http://docwiki.embarcadero.com/RADStudio/en/Delphi_Compiler_Directives_(List)_Index) (including `{$HINTS}`) DO NOT provide a `DEFAULT` option ([`{$WARN}`](http://docwiki.embarcadero.com/RADStudio/en/Warning_messages_(Delphi)) does, for instance). For many directives, you can use [`{$IFOPT}`](http://docwiki.embarcadero.com/RADStudio/en/IFOPT_directive_(Delphi)) to help accomplish what you want (see [this example](https://stackoverflow.com/a/4998442/65863)), however `{$HINTS}` does not work with `{$IFOPT}`, so you are basically SOL in this case. – Remy Lebeau Apr 06 '21 at 18:07

0 Answers0