Bug or feature? std.c.stdlib.exit() breaks RAII

Stewart Gordon smjg_1998 at yahoo.com
Fri Jan 6 19:07:47 PST 2012

On 06/01/2012 14:44, Andrej Mitrovic wrote:
> Just implement your own exception type, e.g. ExitException, and then use:

That's more or less what people have already said.  What's more, Ashish has already 
suggested a further improvement whereby the custom exception carries an exit code.

> void main() { try { realMain(); } catch (ExitException e) { return 0; }
> That should have been int main.

That's not the only typo - you've forgotten to finish that function with a return for if 
ExitException is never thrown and a closing }.


More information about the Digitalmars-d-learn mailing list