C++ Logo

std-proposals

Advanced search

Re: [std-proposals] D3803R0 More standard forms of main

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Wed, 23 Jul 2025 06:55:12 +0000
> Also, "void main()" is still magical, perhaps more so, because it returns EXIT_SUCCESS.

I disagree. It doesn't return anything. It says so right in the signature (void).
The "application returns" EXIT_SUCCESS to whatever part of the OS that instantiated it.
This assumes that there is a part to the OS to "return too" and that it receives a specific type "int" (which it doesn't really).

That is all a system specific implementation detail that can just be encapsulated in a pseudo
"int __main__(int, char**, char**)"
that call's "void main()".
Which I believe is already the case.

Not that I've ever used a "void main()" in fleshed out applications, but that probably it is the only signature out of the bunch that is fully standerdizable given that it need not make any assumptions about the magical OS realm (for example that there is a char** that receives arguments, and that it can receive an int value that doesn't just gets lost into the oblivion).


________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Paul Caprioli via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, July 22, 2025 5:24:12 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>; C++ Proposals <std-proposals_at_[hidden]>
Cc: Paul Caprioli <paul_at_[hidden]>
Subject: Re: [std-proposals] D3803R0 More standard forms of main


> The one interesting question in the proposal is whether "void main()" should be permitted.

I would suggest it is better not to standardize "void main()".
As you pointed out, it only adds complexity since "int main()" still has to be taught.
Also, "void main()" is still magical, perhaps more so, because it returns EXIT_SUCCESS.
Finally, it must be taught that it is unconventional and not supported by older compilers.
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-07-23 06:55:18