|
-
July 23rd, 2002, 05:47 AM
#1
main function
who calls the main function?
-
July 23rd, 2002, 07:12 AM
#2
It varies from system to system. Set a breakpoint at the first instruction in main and have a look at the stack trace.
Succinct is verbose for terse
-
July 23rd, 2002, 07:18 AM
#3
The C(++) runtime will initialize various things and then will call the main() function. What happens before main() is called, heavily depends on the compiler vendor and on the platform the program is compiled for IMHO. You could set a breakpoint at the beginning of main() and walk thru the call stack, if you're curious. For VC++6.0 and W2k the call stack contains:
Code:
main() line 31
mainCRTStartup() line 206 + 25 bytes
KERNEL32! 77e87d08()
I have to admit that I never bothered with the startup process - didn't have to.
-
July 23rd, 2002, 08:48 AM
#4
This ans is specific to VC not standard c++. In VC
mainCRTStartup (define in CRT0.C file) call main. But if you want you can change the entry point by specify the /ENTRY switch. Here is a simple program which has Zee entry point rather than main.
Code:
#pragma comment(linker, "/ENTRY:Zee")
int _stdcall Zee()
{
return 0;
}
Hope it helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|