C++ Logo

std-proposals

Advanced search

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

From: Yexuan Xiao <bizwen_at_[hidden]>
Date: Wed, 23 Jul 2025 23:54:20 +0000
Although in K&R (the book), the main function does not have a return value, I don't see any reason to follow that practice today. For Windows programs, the actual entry point is wWinMain. void main has almost no advantages and doesn't help in teaching either. Maybe we should suggest that the MSVC team warn about void main, especially with option /permissive-.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Jan Schultke via Std-Proposals <std-proposals_at_[hidden]>
Sent: Tuesday, July 22, 2025 18:40
To: C++ Proposals <std-proposals_at_[hidden]>
Cc: Jan Schultke <janschultke_at_[hidden]>
Subject: [std-proposals] D3803R0 More standard forms of main

Hi,

I'm cooking up a draft for a proposal:
https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2FEisenwave%2F78d6127b73c6c9a1bc4cb55ad7bf249c&data=05%7C02%7C%7Ce65b88d2a12249894d8f08ddc90c47ad%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638887776783784974%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=JLSAh7rsex8vyscL0pJhzY%2FhR3sqc6X%2FJLW2%2FeAw3Jg%3D&reserved=0<https://gist.github.com/Eisenwave/78d6127b73c6c9a1bc4cb55ad7bf249c>

In short, the goal is for "int main(int, const char**)" and some other
signatures to be permitted. Many C++ developers probably expect this
to be standard C++ already, but surprisingly, this is voluntarily
supported by implementations despite there being no such requirement.
This borders on being a CWG issue, but I don't think CWG could make
such a decision without consulting EWG anyway, so here we are.

The one interesting question in the proposal is whether "void main()"
should be permitted. I think there are some good arguments in favor of
that, but also good arguments against.

Let me know what you think :)


Jan
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fstd-proposals&data=05%7C02%7C%7Ce65b88d2a12249894d8f08ddc90c47ad%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638887776783819011%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=NQF30ALuqczKFSiY8Y1zdskssc76R3KRgT9xVn%2FlXHM%3D&reserved=0<https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>

Received on 2025-07-23 23:54:28