exit(1)?

Jakob Ovrum via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 16 21:11:24 PST 2015


On Thursday, 17 December 2015 at 05:02:50 UTC, Shriramana Sharma 
wrote:
> http://dlang.org/phobos/std_getopt.html has a line in an 
> example saying exit(1);
>
> Surely this works only if core.stdc.stdlib is imported? Should 
> the example be modified to show the import?
>
> And is exit() the canonical way to exit the current process 
> even in D?

Ouch, that's not good. `exit` is not a good way to terminate a D 
program. It doesn't call destructors, including module 
destructors. The example should be restructured to `return 1;` 
from `main`.



More information about the Digitalmars-d-learn mailing list