In Visual C++ 2013 Professional, when I right-click CWinApp::Run()
, an MFC function, in the afxwin.h
header file and choose "Go To Definition" in the context menu, nothing comes up. The definition is also unavailable on this function's MSDN article. How can I fix the problem and find the definition? What would cause definitions to be unavailable?

- 1,771
- 3
- 17
- 37
3 Answers
You can't go to a definition of a function that exists in the MFC, you don't have access to the debugging information. Generally, you're only going to be able to access the definition of functions you have the source for. You can access the declarations, that's what you see in the header file.
As far as some problem you have, I'd lean toward your own code having a problem, not something in the MFC.

- 527
- 3
- 13
-
Without the definition or even some details of what the functions do, I cannot override them, i.e. [Overridable CWinApp Member Functions](https://msdn.microsoft.com/en-us/library/f6b6stsw.aspx): `InitInstance`, `Run`, `ExitInstance`, `OnIdle`. Yet, that's what's necessarily to make a program, i.e. overriding `InitInstance` to include a `CFrameWnd` or a derivative and a call to `ShowWindow`. I want to override the other functions to get `PeekMessage` functionality instead of `GetMessage`. I cannot do that without knowing what those functions do and how cleanup works. – CodeBricks Jun 09 '15 at 02:51
-
1Took a look around online, you should be able to look at it in Professional. Are you using the debug libraries? [This person](http://stackoverflow.com/questions/23223017/debugger-does-not-step-into-mfc-source-code) seemed to have the same problem, and their symbol libraries weren't loaded properly. – cehnehdeh Jun 09 '15 at 02:56
-
I don't know. How can I find out? – CodeBricks Jun 09 '15 at 02:59
-
1First, if you follow the link I posted, see what module is laoded for MFC. If the library name doesn't end with 'd', it probably isn't the debug library. If that doesn't work, `"I was able to get VS2010 to load the symbol files by going to Tools->Options->Debugging->Symbols and select checkbox "Microsoft Symbol Servers" and now Visual Studio loads PDBs automatically. "`. Try that. – cehnehdeh Jun 09 '15 at 03:02
-
@CodeBricks: In order to find out what function does, you have to read the external specification of that function in the documentation. Looking at the definition of the function is rather useless for that purpose, since you have no way of knowing what parts of its behavior are included into its external spec, and what parts are just implementation details you are not allowed to rely upon. – AnT stands with Russia Jun 09 '15 at 03:02
-
I stuck the hyperlink when I said "This person", here's the raw text: http://stackoverflow.com/questions/23223017/debugger-does-not-step-into-mfc-source-code – cehnehdeh Jun 09 '15 at 03:23
-
@cehnehdeh, +1 because your comments helped me with other related problems, but the accepted answer tells me where exactly to find the definition. – CodeBricks Jun 09 '15 at 03:45
-
No worries! Makes sense – cehnehdeh Jun 09 '15 at 03:52
You can put a break point on any MFC function then debug it, and step in to the function (F11 key
or "Step in" command). This will take you directly to source code, most of the time.
In this case, you may be redirected to this file for VC 2013:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\mfc\appcore.cpp

- 30,904
- 6
- 40
- 77
What Error is shown in the console?
All i can say to help is that you are suposed to call that function in a while loop, like this:
while(CWinApp::Run()){
//application code goes here...
}

- 66
- 8
-
There is no compilation error. I just want to find the definition, but cannot find it. – CodeBricks Jun 09 '15 at 02:36