From b260937ca6751396a9101dfc4501eec8b4bed440 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 3 Apr 2018 14:04:22 +0200 Subject: [PATCH] Use __attribute__((destructor)) on non windows systems. atexit in shared libraries is not universally supported. --- winpr/libwinpr/utils/wlog/wlog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c index 22e79d91a..285df1cc6 100644 --- a/winpr/libwinpr/utils/wlog/wlog.c +++ b/winpr/libwinpr/utils/wlog/wlog.c @@ -78,6 +78,10 @@ static int WLog_ParseLogLevel(LPCSTR level); static BOOL WLog_ParseFilter(wLogFilter* filter, LPCSTR name); static BOOL WLog_ParseFilters(void); +#if !defined(_WIN32) +static void WLog_Uninit_(void) __attribute__((destructor)); +#endif + static void WLog_Uninit_(void) { DWORD index; @@ -152,7 +156,9 @@ static BOOL CALLBACK WLog_InitializeRoot(PINIT_ONCE InitOnce, PVOID Parameter, P if (!WLog_SetLogAppenderType(g_RootLog, logAppenderType)) goto fail; +#if defined(_WIN32) atexit(WLog_Uninit_); +#endif return TRUE; fail: free(g_RootLog);