开发者

Creating a simple VS2008 visualizer inside autoexp.dat (problem with casting)

开发者 https://www.devze.com 2022-12-26 08:46 出处:网络
I have a large project of mixed C/C++. I\'ve created a simple visualizer for the ICU UnicodeString class as follows...

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.开发者_JAVA技巧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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消