I would suggest that this saves the freedom to implement the main prefix with code for building global and static data, accepts any parameters defining the arguments of the environment and command line, and compares them with the argc / argv / env conventions in C ++, constructs the corresponding stack and exception framework for the application to run, etc. Note that not all environments can allow an executable image to have any other character designated as initialization code, which must be run before main() .
Similarly, a cleanup code can be added to main() along with an OS call with some mapping from the 0 / zero-free C and C ++ convention with the actual success / failure values ββused by that particular OS.
Therefore, calling main from another place may try to re-initialize the application framework or force an unintended exit to the OS - it sounds disastrous for me.
Tony Delroy Nov 10 2018-10-11 11:49
source share