Date: Mon, 09 Sep 2024 14:41:27 -0700
On Monday 9 September 2024 13:30:37 GMT-7 Jarrad Waterloo wrote:
> > "there's only *one* main signature."
> some programmers would argue that there are multiple signatures now, see the
> following
>
> https://en.cppreference.com/w/cpp/language/main_function
> see 1, 2 and 3
> 6.9.3.1 main function
> Concerning #3 according to working draft 6.9.3.1
> "Recommended practice: Any further (optional) parameters should be added
> after argv"
Please use proper quoting and please keep the mailing list in Cc, or reply
only to the mailing list.
I understand that that's what programmers think when they see that. That's not
the problem.
The problem is that, from the point of view of the implementation, there's
only *one* main: it's called "main", returns int and takes three parameters:
one int and two char** arrays. That's it. That's how it is implemented, it's
called from exactly one place, always the same way.
> This doesn't even include the C variations and whether the function has to
> return int or just void.
> https://en.cppreference.com/w/c/language/main_function
> If the return type of the main function is not compatible with int (e.g.
> void main(void)), the value returned to the host environment is
> unspecified. If the return type is compatible with int and control reaches
> the terminating }, the value returned to the environment is the same as if
> executing return 0;. since C99
That's just the compiler emitting a "return 0" where you didn't. That's again
not the problem. All this is under the control of the compiler.
The problem is what's not under control of the compiler, which is what calls
main() in the first place.
> > "there's only *one* main signature."
> some programmers would argue that there are multiple signatures now, see the
> following
>
> https://en.cppreference.com/w/cpp/language/main_function
> see 1, 2 and 3
> 6.9.3.1 main function
> Concerning #3 according to working draft 6.9.3.1
> "Recommended practice: Any further (optional) parameters should be added
> after argv"
Please use proper quoting and please keep the mailing list in Cc, or reply
only to the mailing list.
I understand that that's what programmers think when they see that. That's not
the problem.
The problem is that, from the point of view of the implementation, there's
only *one* main: it's called "main", returns int and takes three parameters:
one int and two char** arrays. That's it. That's how it is implemented, it's
called from exactly one place, always the same way.
> This doesn't even include the C variations and whether the function has to
> return int or just void.
> https://en.cppreference.com/w/c/language/main_function
> If the return type of the main function is not compatible with int (e.g.
> void main(void)), the value returned to the host environment is
> unspecified. If the return type is compatible with int and control reaches
> the terminating }, the value returned to the environment is the same as if
> executing return 0;. since C99
That's just the compiler emitting a "return 0" where you didn't. That's again
not the problem. All this is under the control of the compiler.
The problem is what's not under control of the compiler, which is what calls
main() in the first place.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel DCAI Platform & System Engineering
Received on 2024-09-09 21:41:30