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

Andrej Mitrovic andrej.mitrovich at gmail.com
Fri Jan 6 06:44:11 PST 2012


Just implement your own exception type, e.g. ExitException, and then use:

void main() { try { realMain(); } catch (ExitException e) { return 0; }
void exit() { throw ExitException(); }

where realMain is the actual main function. Then just call exit()
whenever you want to.


More information about the Digitalmars-d-learn mailing list