This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Use of atexit for destructors on Solaris 7.
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: Use of atexit for destructors on Solaris 7.
- From: Charles Galambos <c dot galambos at eim dot surrey dot ac dot uk>
- Date: Wed, 22 Mar 2000 10:17:47 +0000
Hi,
> The problem can be worked-around: Don't use block-local static
> variables... Of course, the other proposed work-around (replace atexit
> function, have compiler emit a different function call) also work.
The only reason I use static functions is so I can garantee initalisation
order. I use something like the following code fragment in a number of
places.
MyClassC &AVar() { static MyClassC x; return x; }
This allows me to refer to them in the constructors of other classes that
maybe declared as normal static variables. This gets around the limits
placed by the standard on the expected order of initalisation order of global
variables in different files. This kind of thing is usefull for things like
dynamicly
creating hash tables of IO routines for all the classes linked into an
executable.
Since 'atexit' on solaris is function ptr it can be replaced. (Is this part of
the standard ??) Is there a way I can replace the atexit function before or
at
least early in the initilisation of static variables ?
It would have been good also if failure of the atexit function wasn't silently
ignored, especailly as most implementations seem to have a limit of the
the number of times it can be called.
Thanks,
Charles.