How do I force the linker to include a function I need during debugging?

后端 未结 3 535
名媛妹妹
名媛妹妹 2021-01-04 11:13

I often make small methods to assist debugging, which aren\'t used in the actual program. Typically most of my classes has an AsString-method which I add to the watches. I k

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 12:05

    sveinbringsli ask: "Do you have a tip for unit functions also?"

    Delphi compiler is smart... So you can do something like...

    unit UnitA;
    
    interface
    
    {$DEFINE DEBUG}
    
    function AsString: string;
    
    implementation
    
    function AsString: string;
    begin
      Result := 'Test: ';
    end;
    
    {$IFDEF DEBUG}
    initialization
      exit;
      AsString;
    {$ENDIF}
    end.
    

提交回复
热议问题