From fa0f4825937ed93163bb2cd165c001d7444d8928 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Thu, 16 Mar 2017 10:31:19 -0700 Subject: Last try at getting linktime registration working under MSVC --- include/libsurvive/survive.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 2663c57..deb91c4 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -149,6 +149,7 @@ void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode #define INITIALIZER2_(f,p) \ __declspec(dllexport) void f(void); \ __declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \ + volatile static void * LTRegistrationPinnerFor##f = &##f; \ __pragma(comment(linker,"/include:" p #f "_")) \ void f(void) #ifdef _WIN64 @@ -176,6 +177,9 @@ void RegisterDriver( const char * name, void * data ); #define REGISTER_LINKTIME( func ) \ __declspec(dllexport) void LTRegister##func() { RegisterDriver( #func, &func ); } \ INITIALIZER(LTRegister##func) + + + //void __attribute__((constructor)) LTRegister##func() { RegisterDriver(#func, &func); } -- cgit v1.2.3