Use __attribute__((destructor)) on non windows systems.
authorArmin Novak <armin.novak@thincast.com>
Tue, 3 Apr 2018 12:04:22 +0000 (14:04 +0200)
committerArmin Novak <armin.novak@thincast.com>
Tue, 3 Apr 2018 12:04:22 +0000 (14:04 +0200)
atexit in shared libraries is not universally supported.

winpr/libwinpr/utils/wlog/wlog.c

index 22e79d9..285df1c 100644 (file)
@@ -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);