Recently, I got a crash dump file from a customer. I could track the problem down to a class that could contain incorrect data, but I only got a void-pointer to the class, not a real pointer (void-pointer came from a window-property, therefore it was a void-pointer). Unfortunately, the class to which I wanted to cast the pointer to, was in an anonymous namespace, like this:
namespace
{
class MyClass
{
...
};
}
...
void *ptr = ...
// I know ptr points to an instance of MyClass,
// and at this location I want to cast ptr to (MyClass *) in the debugger.
Using "ptr" in the watch window if Visual Studio 2005 just shows the pointer value. If I use "(MyClass *)ptr", the debugger tells me it cannot cast to it.
How can I cast the ptr to a MyClass-pointer?
Note: I could eventually use a silly-named namespace (like the name of the source file), and then use a "using namespace", but I would expect better solutions.