• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Destructor and exit()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Destructor and exit()
      • From: Steve Checkoway <email@hidden>
References: 
 >Destructor and exit() (From: Eric Shepherd <email@hidden>)
 >Re: Destructor and exit() (From: Markus Hitter <email@hidden>)

  • Prev by Date: Re: API search no longer works after an update?
  • Next by Date: Re: API search no longer works after an update?
  • Previous by thread: Re: Destructor and exit()
  • Next by thread: Re: Destructor and exit()
  • Index(es):
    • Date
    • Thread