C++ Logo

std-proposals

Advanced search

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

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Tue, 22 Jul 2025 19:54:26 +0300
On 22 Jul 2025 19:33, Brian Bi via Std-Proposals wrote:
>
> On Tue, Jul 22, 2025 at 12:24 PM Paul Caprioli via Std-Proposals <std-
> proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>> wrote:
>
> > 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.
>
> I don't think we have to teach people that `void main()` "returns
> `EXIT_SUCCESS`". Observing the return code of `main` is not a beginner
> topic.

Observing the exit code of a program is the most basic thing, more basic
than any level of C/C++ expertise.

`void main()` makes the behavior even more obscure than an `int main()`
without an explicit `return` statement. If anything, I would like if
`return` was made mandatory in `main`, or, at least, encourage people
towards having it, as the first step. Although at this point there's
plenty of code that don't have it, so this idea likely won't go far.

Received on 2025-07-22 16:54:32