Nick Keighley wrote:
On 5 Feb, 16:16, Andre Kostur <nntps...@kostur.netwrote:
>"Nick Keighley" <nick_keighley_nos...@hotmail.comwrote innews:11**********************@m58g2000cwm.google groups.com:
>>Hi,
I want a particular function to run after everything has beeen
destructed.
It's looking for memory leaks.
atexit() doesn't seem to suit my purpose as global statics can be
destructed
after all the atexit()s.
Would a global static at the beginning of the file containing main()
do the job
or have I run into another aspect of the "static initialization order
fiasco"?
Compiler-dependant. A global static at the beginning of the translation
unit containing main() will only be known to have been constructed before
main, but not necessarily before global objects in other translation units.
so the question is not, portably, answerable? There is no easy way to
generate
a last function or DTOR?
--
Nick Keighley
Perhaps too intrusive/fragile for your needs, but you could modify every
translation unit to have a global variable of some type T as the first
thing in that translation unit. T could have a static reference
counter, and when ~T() is executed with reference count 1, that should
be the last thing to execute.
--
Alan Johnson