diff --git a/sdk/lib/crt/startup/crtexe.c b/sdk/lib/crt/startup/crtexe.c index efc29191191..a09d4b5b441 100644 --- a/sdk/lib/crt/startup/crtexe.c +++ b/sdk/lib/crt/startup/crtexe.c @@ -115,6 +115,10 @@ _CRTALLOC(".CRT$XCAA") _PVFV mingw_pcppinit = pre_cpp_init; extern int _MINGW_INSTALL_DEBUG_MATHERR; +#ifdef __GNUC__ +extern void __do_global_dtors(void); +#endif + static int __cdecl pre_c_init (void) { @@ -211,8 +215,6 @@ int __cdecl mainCRTStartup (void) return ret; } -void __call_atexit(); - static __declspec(noinline) int __cdecl @@ -326,7 +328,11 @@ __tmainCRTStartup (void) #endif mainret = main (argc, argv, envp); #endif - __call_atexit(); + +#ifdef __GNUC__ + __do_global_dtors(); +#endif + if (!managedapp) exit (mainret); diff --git a/sdk/lib/crt/startup/gccmain.c b/sdk/lib/crt/startup/gccmain.c index a1cd04b026e..3370a126947 100644 --- a/sdk/lib/crt/startup/gccmain.c +++ b/sdk/lib/crt/startup/gccmain.c @@ -43,8 +43,6 @@ __do_global_ctors (void) { __CTOR_LIST__[i] (); } - - atexit (__do_global_dtors); } static int initialized = 0;