In Visual C++ 2010, consider the following:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
struct MyClass
{
MyClass() : mMember(0)
{}
void Func()
{
int tmp = 0;
tmp++;
}
private:
int mMember;
};
MyClass inst;
inst.Func();
return 0;
}
Step inside Func() and go to Watches pane and watch member variable mMember. Instead of seeing its value, you’ll see the error
CXX0033: Error: error in OMF type information
Is it possible to get the debugger to display the member’s value? If so, How?
I am aware this might be a bug, I have already reported it on Microsoft Connect, I am now looking for a workaround (that does not involve moving the definition outside function scope), and an explanation as to why this is occurring.
The bug report I submitted can be found here:
https://connect.microsoft.com/VisualStudio/feedback/details/760149/visual-c-2010-cant-view-local-class-members-in-debugger-cxx0033-error-error-in-omf-type-information
Edit: I am fully aware classes defined outside function scope work properly.
Edit2: A reference to an already submitted and acknowledged bug to Microsoft with this issue would go a long way towards becoming an accepted answer. I have searched for one already and found none.
It’s a bug, VS2008 has it too, but it was fixed in VS2012 so they’ll surely quickly close your feedback article.
A workaround is going to be difficult, the debugger doesn’t have type info for this. Which also makes it give up the ghost on the watch expression. Technically you can use Debug + Windows + Memory + Memory1 and type “this” in the Address expression. The “somevarname” is the first member and the struct doesn’t have a v-table so you’ll have no trouble finding the value. Clearly this doesn’t scale very well.