The C ++ standard states that the main function cannot be inlined, in response to @Tomalak Geret'kal. This answer discusses the possibility of nesting the main function, whether there was a limitation in standard deletion.
Inline definition
The inline is a suggestion to the compiler to insert the contents of an in-situ function. One of the intentions is to remove the overhead when calling and returning from a function (subroutine).
An important embedding situation is when there is a pointer to a function. In this case, there must be at least one static copy of the function. In this case, the linker may allow "external links" to the built-in function, since there is one static version.
It is important to note that the compiler and linker determine whether to insert content or call one instance of a function.
It should also be noted that functions that are not marked by the programmer can also be built in by the compiler.
Attachment of the main function
Since only one call to main allowed , how is it associated with the compiler. Individual instances of built-in functions may be standard. The compiler is allowed to convert the inlined function into a function call for a single instance. Thus, the compiler ignores the built-in clause for the main function.
The compiler and linker must ensure that there is only one instance of the main function built-in. This is where the hard part comes in, especially with external communication. One process for providing a single instance is to leave information that the translation has a “core” function, regardless of whether it is built-in. Note. When a built-in function is called, the compiler is allowed to remove the function from the symbol tables for external binding, since the idea is that the function will not be called by external functions.
Summary
Technically, there is nothing to prevent the inclusion of the main function. A mechanism already exists to convert built-in functions into individual instances and to identify multiple instances of a function. When there is a pointer to an inline function, one instance of the function is created, so it has an address. This mechanism satisfies the requirements of the runtime library for main with an address. In the case of inline for the main function, it will be ignored, but there should be no reason to prevent this syntax (except for confused people). In the end, there are already cases of syntax that are redundant, for example, declaring a parameter that is passed by value (copy) as const .
"This is just my opinion, I could be wrong." - Dennis Miller, comedian.