4

Basically my problem is that I expect Visual Studio (2010 Professional) to be able to evaluate any Visual C++ expression in the watch window that it handles in the code I'm debugging, but apparently there's something preventing this from happening. For example, when dealing with CStrings, evaluating the method IsEmpty on the CString in the watch window gives me a Member function not found error, as does a basic equality comparison (in the code being debugged obviously no problems).

Am I missing something here, or is what I'm asking for too much? Obvious solution would be to put debugging statements in my code for whatever CString operation I'm looking for, but I would prefer not to have to do this.

Update/Example:

CString blah = _T("blah");

Calling blah.IsEmpty() in my code works fine, but in the watch window of the debugger I get the error above (CXX0052). The contents of the variable blah can be seen the watch window.

2
  • It fails for your current project or for any project you create? What version of VS do you have? Can you create a demo project to reproduce the problem and post a code snippet here that give you the same warning?
    – higuaro
    Jun 12, 2012 at 15:05
  • I'm working with several MFC projects in VS 2010 Professional (updated above). Just created a new MFC project (sample Microsoft project) to try it out there, too; same problem. I'll add a snippet. Jun 12, 2012 at 15:17

1 Answer 1

6
+50

I could reproduce your problem, and, indeed, the VS watch window shows Member function not found alongside with the error code CXX0052. enter image description here

In the MSDN documentation I found that this problem arises due to a call of a inlined function, the CString::IsEmpty() member function is probably somehow inlined (this is what the Watch Window evaluator sees), to solve the problem, first open your project Configuration and disable inlining

enter image description here

Second, still in the project Configuration, choose Use MFC in a Static Library (somehow the Watch Window keep seeing the called function as an inlined one if you use it as shared library, maybe this is because in the Shared Library the code is inlined and the Watch Window evaluator don't use the Debug builds of such runtime libraries).

enter image description here

Third, clean and Rebuild your Solution.

After that, the problem should be fixed (remember to refresh the expression if you see the value grayed out in the watch panel) during debugging. Remember to switch back to your original Debug options or better, create a new Debug profile to keep this settings.

enter image description here

10
  • Thanks for the detailed answer, I followed your steps (had also to add #define _AFXDLL because of the settings Use MFC in a Static Library and the Multithreaded DLL flag (/MD) required by the project), was able to compile, link and run, but unfortunately had the same problem as before with the watch window evaluator. I'll try it again and/or for another project. Jun 13, 2012 at 12:05
  • I tried this with another project, same steps, same result. Both projects rely on other DLL's, and the second is also a DLL that obviously relies on another EXE file to run. You don't think I need to also build the other DLL's and the EXE with the altered settings, do you? I was debugging the altered binary and had the breakpoint in the respective codebase, so that shouldn't matter. But I suppose something to try nevertheless.... Jun 14, 2012 at 13:40
  • @newenglander Could you please post that project somewhere?, so I can download it and toy with the Configuration to spot the missed parameters that maybe fix the problem. Sure are another set of options that get rid of the CXX052 warning
    – higuaro
    Jun 15, 2012 at 3:07
  • Thanks for the offer, the problem is the project depends on several other projects/DLLs, so there'd be quite a lot to send. I'll have to request permission to share this. I could see if we have a similar project without so many dependencies (or create one). But I'll have to wait till next week, no access to the files now. Jun 15, 2012 at 15:33
  • @newenglander Sorry, I thought that the project was a test project, can you please tell me (step by step) how to reproduce a basic version of your set of projects?
    – higuaro
    Jun 17, 2012 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.