How do I properly exit from a D program (outside main)?

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 15 23:07:38 PDT 2014


On 16/09/14 02:06, AsmMan wrote:

> Neither assert or return will help. Check out this code example:
>
> void main() {
> f();
> }
>
> void f() {
>    if(!foo)
>      exit(1);
>     do_something();
> }

If you want to exit the application with exit code 1 then it sounds like 
something has gone wrong. In that case, throw an exception instead.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list