Date: Sat, 7 Sep 2024 16:49:47 +0000
argc arv is not the only pattern of arguments to a "main like" function, it's also possible to have an additional envp.
On windows it's better to use wchar_t instead of char in order to cause less issues; but it's also possible to use WinMain instead and this is preferred for native apps, and it doesn't have an argument list; if you are writing a service the required entry point is again something else different.
As far as the way I use them, entry points are platform/application specific, and there's no point in standardizing it.
You can very easily write a wrapper yourself that gives you this behavior if that's what you want.
I personally would never use it in this way anyway.
that's my 2c
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Jeremy Rifkin via Std-Proposals <std-proposals_at_[hidden]>
Sent: Saturday, September 7, 2024 5:37:22 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Jeremy Rifkin <jeremy_at_[hidden]>
Subject: [std-proposals] Floating an idea: int main(std::span<std::string_view> args)
Hello,
I'd like to propose adding int main(std::span<std::string_view> args) as
a standard signature for main.
Motivation:
- Modernization
- Ergonomics
- Teachability
- Modern C++ through and through instead of 'what's a char**' and
'argv[1] == "--help" is a footgun, beware'
Considerations:
- There would be slight startup overhead in constructing the
std::string_views and underlying array of string views, however, this
would be entirely opt-in
- It would probably add some implementation complexity
- This would be an aspect of the core language which depends on the
standard library. I don't love that, but, there is precedence for this
sort of thing
- Direct mutability of the argument contents would be lost
I would make a reference implementation as part of the proposal.
Cheers,
Jeremy
On windows it's better to use wchar_t instead of char in order to cause less issues; but it's also possible to use WinMain instead and this is preferred for native apps, and it doesn't have an argument list; if you are writing a service the required entry point is again something else different.
As far as the way I use them, entry points are platform/application specific, and there's no point in standardizing it.
You can very easily write a wrapper yourself that gives you this behavior if that's what you want.
I personally would never use it in this way anyway.
that's my 2c
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Jeremy Rifkin via Std-Proposals <std-proposals_at_[hidden]>
Sent: Saturday, September 7, 2024 5:37:22 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Jeremy Rifkin <jeremy_at_[hidden]>
Subject: [std-proposals] Floating an idea: int main(std::span<std::string_view> args)
Hello,
I'd like to propose adding int main(std::span<std::string_view> args) as
a standard signature for main.
Motivation:
- Modernization
- Ergonomics
- Teachability
- Modern C++ through and through instead of 'what's a char**' and
'argv[1] == "--help" is a footgun, beware'
Considerations:
- There would be slight startup overhead in constructing the
std::string_views and underlying array of string views, however, this
would be entirely opt-in
- It would probably add some implementation complexity
- This would be an aspect of the core language which depends on the
standard library. I don't love that, but, there is precedence for this
sort of thing
- Direct mutability of the argument contents would be lost
I would make a reference implementation as part of the proposal.
Cheers,
Jeremy
-- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2024-09-07 16:49:51