D exit() function?
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sun Mar 25 14:12:47 PDT 2007
"Krzysztof Szukielojc" <krzysztof.szukielojc at gmail.com> wrote in message
news:eu6m78$m1r$1 at digitalmars.com...
>
> I think simple scope(exit) should do the trick.
>
> void exitFun(){
> ...
> }
>
> void main(){
> scope(exit) exitFun();
> ...
> }
>
No, I'm not looking for an atexit() replacement, sorry. I'm looking for a
way to end my D program at an arbitrarily deep call depth and still have it
call the RTL cleanup functions.
I suppose it would be possible to do something like:
extern(C) void _cleanupD()
{
_moduleDtor();
gc_term();
}
..
void main()
{
atexit(&_cleanupD);
// program
}
But that's horribly non-portable.
Something like this should be in Phobos.
More information about the Digitalmars-d-learn
mailing list