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

后端 未结 3 1207
無奈伤痛
無奈伤痛 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条回答
  •  执笔经年
    2021-02-20 01:42

    I don't have a Delphi compiler available at the moment, but rearranging the code to remove the if..else might make the warning go away:

    function TfrmNagScreen.Run: TOption;
    begin
      if ShowModal <> mrOk then
        Abort;
    
      Result := TOption(rdgAction.EditValue);
    end;
    

    See also How to disable a warning in Delphi about “return value … might be undefined”?.

提交回复
热议问题