This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: static constructors/destructors and atexit



I wrote:
> > We can conform to the standard simply by using atexit() to do local
> > static destruction.
> 
> Excuse me, but why complicate it so much? Why can't we simply make the
> compiler replace the user-level atexit() calls with our own atexit() with
> no limits? This way we would conform to the standard, right?

Yes, on platforms where we control the C library, or where atexit
is not crippled, that is the solution: just use atexit().

However, on some systems, atexit() is tightly integrated with the startup
function (the one that calls main() ), and it may be more difficult to
replace.  On Solaris, it appears that you would have to replace exit()
as well (since exit() calls the handlers registered by atexit()).  And
as someone pointed out, with shared libraries linked against libc it
might be difficult to force the replacement function to be called.






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]