From f43528035a5b0953a3e049e8a83cfc5dc994283f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 16 Nov 2007 01:27:02 -0800 Subject: [PATCH] Check for GCC's destructor attribute before using it --- CMakeLists.txt | 3 +++ OpenAL32/OpenAL32.c | 2 ++ config.h.in | 3 +++ 3 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aceb1ab..3084042c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,9 @@ ELSE() # Set visibility options if available IF(NOT "${WIN32}") + CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor)); + int main() {return 0;}" HAVE_GCC_DESTRUCTOR) + CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\"))); int main() {return 0;}" HAVE_GCC_VISIBILITY) IF("${HAVE_GCC_VISIBILITY}") diff --git a/OpenAL32/OpenAL32.c b/OpenAL32/OpenAL32.c index dab7ec31..b638d945 100644 --- a/OpenAL32/OpenAL32.c +++ b/OpenAL32/OpenAL32.c @@ -46,6 +46,7 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) return TRUE; } #else +#ifdef HAVE_GCC_DESTRUCTOR static void my_deinit() __attribute__((destructor)); static void my_deinit() { @@ -59,3 +60,4 @@ static void my_deinit() DeleteCriticalSection(&g_mutex); } #endif +#endif diff --git a/config.h.in b/config.h.in index d8c26def..931d16ae 100644 --- a/config.h.in +++ b/config.h.in @@ -40,4 +40,7 @@ /* Define to the size of a void pointer type */ #cmakedefine SIZEOF_VOIDP ${SIZEOF_VOIDP} +/* Define if we have GCC's destructor attribute */ +#cmakedefine HAVE_GCC_DESTRUCTOR + #endif -- 2.11.4.GIT