By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,404 Members | 980 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,404 IT Pros & Developers. It's quick & easy.

atexit() and DLLs

P: n/a
Hi,

I'm using a phoenix singleton template in a DLL for windows which is using
the atexit()
function to call the objects destructor in case
the object had to be recreated with placement new after destruction.

Now.. how does the atexit() function work in this case? If atexit() is
called from within the DLL, will the secified
functions be called when the DLL is unloaded? (good)
Will they be called when the progam terminates? (bad)
Will this not work at all an crash for sure? (worse)

I'm using VC++ in case that makes a difference.

Thanks
Mar 9 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 2007-03-09 10:23, Andreas Schmitt wrote:
Hi,

I'm using a phoenix singleton template in a DLL for windows which is using
the atexit()
function to call the objects destructor in case
the object had to be recreated with placement new after destruction.

Now.. how does the atexit() function work in this case? If atexit() is
called from within the DLL, will the secified
functions be called when the DLL is unloaded? (good)
Will they be called when the progam terminates? (bad)
Will this not work at all an crash for sure? (worse)

I'm using VC++ in case that makes a difference.
No, it does not because this is off topic here, where we discuss only
the C++ language itself. Your question is better asked in a win32-
programming group, perhaps you can find one in
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
To answer your question: I don't think atexit() is the right function to
use, better would be to use DllMain(), pay special attention to the
fdwReason argument. More details can be found here
http://msdn2.microsoft.com/en-us/library/ms682583.aspx

--
Erik Wikström
Mar 9 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.