views:

338

answers:

1

I have a large project of mixed C/C++. I've created a simple visualizer for the ICU UnicodeString class as follows...

[inside autoexp.dat]
icu_4_2::UnicodeString {
        preview     ([$c.fUnion.fFields.fArray,su])
}

...and that works fine. Inside the debugger wherever I see the object I now see the text inside in the preview line.

I then created a wrapper class containing one of these objects as follows...

class StringHandleData
{
public:
    icu_4_2::UnicodeString str;
};

...and then created another visualizer for this...

[inside autoexp.dat]
StringHandleData {
    preview     ([$c.str.fUnion.fFields.fArray,su])
}

...which again, works fine. Whenever I see a StringHandleData object in the debugger I see the text inside in the string.

However, my problem comes when I define a typedef I can use inside C code like this...

typedef void* StringHandle;

...which under the hood is actually just a ptr to a StringHandleData object. So when I try and create a visualizer for the StringHandle type like this...

[inside autoexp.dat]
StringHandle {
    preview     ([((StringHandleData)$c).str.fUnion.fFields.fArray,su])
}

...it doesn't work. I've tried lots of other ways of casting the object too but with no luck so far. If I go to my watch window and cast a StringHandle like this... (StringHandleData*)stringHandle then the debugger makes the cast and previews correctly - but I just can't seem to get it to do it automatically from inside autoexp.dat

Thanks for any help.

A: 

Visual studio's visualiser is blind to typedefs and will think StringHandle is a void *.

Charles Beattie