I like this feature request

I like this feature request

{$BEGINOPT R+,Q-}
...
{$ENDOPT}

https://quality.embarcadero.com/browse/RSP-14045
https://quality.embarcadero.com/browse/RSP-14045

Comments

  1. I assume you want the options to return to their previous settings at ENDOPT ?

    That would indeed be nice.

    ReplyDelete
  2. yes, it's to avoid such things

    {$IFOPT R+}
    {$DEFINE R_PLUS}
    {$R-}
    {$ENDIF}
    ...

    {$IFDEF R_PLUS}
    {$R+}
    {$UNDEF R_PLUS}
    {$ENDIF}

    ReplyDelete
  3. Make an inc file with this content:

    {$IFNDEF R_PLUS}
      {$IFOPT R+}
        {$DEFINE R_PLUS}
        {$R-}
      {$ENDIF}
    {$ELSE}
      {$R+}
      {$UNDEF R_PLUS}
    {$ENDIF}

    And then just include it where to turn on and off.

    ReplyDelete
  4. Stefan Glienke And you can create a collection of include files TURN_R_OFF.inc, TURN_R_ON.inc, TURN_Q_ON.inc etc :)

    ReplyDelete
  5. IMO better approach is {$PUSH}/{$POP}:
    {$PUSH}
    {$R+}{$Q-}
    ...
    {$POP}

    ReplyDelete
  6. Maciej Izak yes...but what's included in PUSH/POP, everything ? why not...or perhaps

    {$PUSH R,Q,ZEROBASEDSTRINGS}
    {$IFDEF WIN64}
    {$R-}
    {$ENDIF}
    ...
    {$POP}

    ReplyDelete
  7. Push/Pop would allow you to use the longform of the switches.

    ReplyDelete
  8. Lars Fosdal yes, and you can play with flags like in my sample above (WIN64)...I've added a comment about that.

    ReplyDelete
  9. ...additionally {$PUSH}/{$POP} is compatible with FPC :)

    ReplyDelete

Post a Comment