Re: Avoiding destructors while still calling atexit handlers
Re: Avoiding destructors while still calling atexit handlers
- Subject: Re: Avoiding destructors while still calling atexit handlers
- From: Steve Checkoway <email@hidden>
- Date: Fri, 6 Jan 2006 13:12:52 -0800
On Jan 6, 2006, at 11:09 AM, Brad Oliver wrote:
What's the cleanest way to avoid calling the C++ destructor chain
while still calling routines registered with atexit()?
Call exit(3).
$ cat atexit.cpp
#include <cstdlib>
#include <cstdio>
#include <unistd.h>
void bar() { puts( __func__ ); }
struct foo { ~foo() { puts( __func__ ); } };
int main()
{
atexit( bar );
foo f;
exit( 0 );
}
$ g++ atexit.cpp
$ ./a.out
bar
If you replace the exit( 0 ); with return 0;, the output is
$ ./a.out
~foo
bar
- Steve
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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