How can I temporarily disable the “return value might be undefined” warning?

后端 未结 3 1260
無奈伤痛
無奈伤痛 2021-02-20 01:25

I want to disable a specific warning (W1035) in my code, since I think that the compiler is wrong about this warning:

function TfrmNagScreen.Run: TOption;
begin
         


        
3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-20 02:06

    you can't disable this warning globally, but you can use the {$WARN NO_RETVAL OFF} to disable locally the warning.

    {$WARN NO_RETVAL OFF}
    function TfrmNagScreen.Run: TOption;
    begin
      if ShowModal = mrOk then
        Result := TOption(rdgAction.EditValue)
      else
        Abort
    end;
    {$WARN NO_RETVAL ON}
    

提交回复
热议问题