I wonder that can sure order between destruction of global object and atexit in C++
I have a global object and register atexit function like below:
static MyClass g_class;
void onExit()
{
// do some destruction
}
int main()
{
atexit(onExit);
return 0;
}
I've found onExit() is invoked before MyClass::~MyClass() in Visual Studio 2012 and gcc4.7.2. Am I sure that onExit is always invoked before global object(like g_class) destruction?
I wonder global object register order and atexit register order use same order table.
Or there is no relation between global object order and atexit order?
Edited : Sorry I wrote a mistake. I'm so confused while tidying example code. onExit() is invoked before ~MyClass().