Re: Destructor and exit()
Re: Destructor and exit()
- Subject: Re: Destructor and exit()
- From: "Alexey Proskuryakov" <email@hidden>
- Date: Sat, 03 Sep 2005 21:09:41 +0400
On Fri, 2 Sep 2005 21:17:07 +0200 Markus Hitter <email@hidden> wrote:
I have a C++ program that originated on Windows that relies on
objects' destructors being called when exit() is called in order to
save the application's state to disk. However, when built with gcc
3.3 on Mac OS X, the destructors are never getting called.
This is expected for all versions of gcc. I don't know about other
compilers.
FWIW, for me the destructor is being called (10.4.2, gcc 3.3):
#include <stdio.h>
#include <stdlib.h>
struct S {
S() { printf("ctor\n"); }
~S() { printf("dtor\n"); }
};
S s;
int main()
{
static S s;
exit(0);
}
$ ./a.out
ctor
ctor
dtor
dtor
Did I misunderstand the quesiton and/or the answer?
See also: <http://cpptips.hyperformix.com/cpptips/exit>.
- WBR, Alexey Proskuryakov
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden