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

后端 未结 3 456
名媛妹妹
名媛妹妹 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 11:46

    Maybe it works to call them in some initialization section, guarded by {IFDEF DEBUG} or {IFOPT D+}.

    0 讨论(0)
  • 2021-01-04 11:59

    You can make function published.

      TMyClass = class
        F : integer;
      published
        function AsString : string;
      end;
    

    And switch on in 'Watch Properties' 'Allow function calls'

    0 讨论(0)
  • 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.
    
    0 讨论(0)
提交回复
热议问题