From c031b4d5d07703e179f258e74fdfbd8e6b66e9ef Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 27 Apr 2011 16:33:44 -0700 Subject: Allow MSVC to build a static lib Based on a patch by Michał Cichoń MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Alc/ALc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index 330a177c..078b168a 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -408,6 +408,7 @@ static void alc_deinit(void) __attribute__((destructor)); static void alc_init(void); static void alc_deinit(void); +#ifndef AL_LIBTYPE_STATIC BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) { (void)lpReserved; @@ -426,6 +427,23 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) } return TRUE; } +#elif defined(_MSC_VER) +#pragma section(".CRT$XCU",read) +static void alc_constructor(void); +static void alc_destructor(void); +__declspec(allocate(".CRT$XCU")) void (__cdecl* alc_constructor_)(void) = alc_constructor; + +static void alc_constructor(void) +{ + atexit(alc_destructor); + alc_init(); +} + +static void alc_destructor(void) +{ + alc_deinit(); +} +#endif #endif #endif -- cgit v1.2.3