Order between destruction of global object and atexit in C++
问题 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