File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -188,10 +188,15 @@ typedef struct mjSDF_ mjSDF;
188188 static void _mjplugin_init(void)
189189#elif defined(_MSC_VER )
190190 #pragma section(".CRT$XCU", read)
191- #define mjPLUGIN_LIB_INIT \
192- static void _mjplugin_init(void); \
193- __pragma(warning(suppress: 4189)) __declspec(allocate(".CRT$XCU")) static void (*_mjplugin_init_ptr)(void) = _mjplugin_init; \
194- static void _mjplugin_init(void)
191+
192+ #define mjPLUGIN_LIB_INIT \
193+ static void __cdecl _mj_init_##__COUNTER__(void); \
194+ /* The 'used' attribute for the linker */ \
195+ __declspec(allocate (".CRT$XCU" )) \
196+ static void (__cdecl * _mj_ptr_ ##__COUNTER__ )(void ) = _mj_init_ ##__COUNTER__ ; \
197+ /* This pragma prevents the linker from optimizing this specific pointer away */ \
198+ __pragma (comment (linker , "/include:" "_mj_ptr_" #__COUNTER__ )) \
199+ static void __cdecl _mj_init_ ##__COUNTER__ (void )
195200#endif
196201
197202// function pointer type for mj_loadAllPluginLibraries callback
You can’t perform that action at this time.
0 commit comments