Proper way to exit with specific exit code?
Jacob Carlborg
doob at me.com
Sat Sep 19 06:11:15 UTC 2020
On 2020-09-17 16:58, drathier wrote:
> What's the proper way to exit with a specific exit code?
>
> I found a bunch of old threads discussing this, making sure destructors
> run and the runtime terminates properly, all of which seemingly
> concluding that it's sad that there isn't a way to do this easily, but
> hopefully things have changed in the last 5-10 years and I'm just
> missing the obvious solution.
The proper way is:
int main()
{
return 42;
}
I highly recommend against trying to terminate the application using
`exit` or any other way. Just let the control flow return back to the
`main` function.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list