atexit() and DLLs

  • Thread starter Andreas Schmitt
  • Start date
A

Andreas Schmitt

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
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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-lite/how-to-post.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top