Tuesday 15 June 2010

Can I implement .ToString() on C++ structs for debugging purposes? -



Can I implement .ToString() on C++ structs for debugging purposes? -

in c#, if define struct, can override tostring(). when i'm debugging , add together watch or hover mouse on instance of struct, tooltip computed tostring() rather type name of struct.

can in c++ and/or c++/cli somehow? is, can define method part of struct (or else) cause watch-value/tooltip display string of choosing? default string rendering in visual studio c/c++ list of struct's field values (or many can jammed little box).

my types c-style structs. (it written in c before converted files .cpp , fixed type issues run in cli.) here's illustration struct:

struct other_dollars_node { struct other_dollars_node *next_other_dollars; override *overrides; long other_dollars_id; tm effective_date; double amount; }

i have little experience c++/cli -- of experience has been native c/c++ , c#. i'm using visual studio 2013.

update: since existing code uses native c syntax, , prefer solution works without having refactor it, cli aspect may less important.

i think want provide debugger visualization native structs. did little searching on msdn, , found page: create custom views of native objects in debugger.

basically, need add together file c:\program files (x86)\microsoft visual studio 11.0\common7\packages\debugger\visualizers tell visual studio how show structs in debugger window. there many examples there, , link above provides explanation, though admit haven't tried myself.

c++ c visual-studio visual-c++ c++-cli

No comments:

Post a Comment