For a sample 开发者_StackOverflow中文版program, though this is doing all good for me. But I was wondering how is it happening.
I created a console application with "MFC" checkbox enabled while creating the project (VC2008).
It created standard _tmain
implementaion with AfxWinInit
calls and all. Then I wrote my custom function Main
and called it from _tmain
itself.
Now as soon as press F10 or F11 to START debugging, it goes into Main
and not _tmain
(yes, via _tmain
itself) - How and Why - that's the question.
No I didn't set any project setting at all. this is about 32-bit Debug build.
EDIT: The interesting thing is this:
#include "stdafx.h"
void Main()
{
printf("This is custom main");
}
int _tmain(int argc, _TCHAR* argv[])
{
if(false) // Getting fooled, or fooling us?
Main();
return 0;
}
Visual Studio considers Main
as entry point, and doesn't do anything when I start debugging with F10/F11 - since false
is false and doesn't allow Main
to be called!
My test shows it goes to _tmain
first, before custom Main
.
精彩评论