Let's look at the underlying CompilationCode:
_ Start:
:
Init stack;
Init heap;
Open stdin;
Open stdout;
Open stderr;
:
Push argv;
Push argc;
Call _ main; (Call Main)
:
Destory heap;
Close stdin;
Close stdout;
Close stderr;
:
Call _ exit;
We can see that the main function is just a function call.
Before calling the main function, it will initialize the stack, heap, open the standard input, output, error stream, and pressure the parameter stack. There are also some global variables, objects and static variables, object space allocation and initial values.
After calling the main function, destroy heap memory and disable standard input, output, and error streams.
These are all automatically generated by the compiler to help us start the main function.
Original article: http://blog.csdn.net/hongchangfirst/article/details/8807533
Author:Hongchangfirst
Hongchangfirst home: http://blog.csdn.net/hongchangfirst