13 #ifndef ML_LIBRARY_INIT_MACROS_H
14 #define ML_LIBRARY_INIT_MACROS_H
24 #pragma warning(disable : 4786 )
28 #if !defined(AFX_STDAFX_H__17533C48_9DB6_4FA8_AEC3_550E71AF7183__INCLUDED_)
29 #define AFX_STDAFX_H__17533C48_9DB6_4FA8_AEC3_550E71AF7183__INCLUDED_
35 #ifndef WIN32_LEAN_AND_MEAN
36 #define WIN32_LEAN_AND_MEAN
39 #ifndef ML_SUPPRESS_LIBRARY_INIT_MACROS_WINDOWS_H_INCLUDE
40 #include <ThirdPartyWarningsDisable.h>
42 #include <ThirdPartyWarningsRestore.h>
82 #define ML_LIBRARY_USER_DESTROY_CODE
103 #define ML_INIT_LIBRARY_EXT_3(initMethod, NAMESP, LIB_TARGET) \
104 BOOL APIENTRY DllMain( HANDLE , \
105 DWORD ul_reason_for_call, \
110 switch (ul_reason_for_call){ \
111 case DLL_PROCESS_ATTACH: \
114 ML_UTILS_NAMESPACE::Runtime::setRecentlyLoadedDllName(#LIB_TARGET); \
118 MLCheckCPPAPILinkCompatibility(ML_MAJOR_VERSION, \
119 ML_MAJOR_CAPI_VERSION, \
129 NAMESP::initMethod(); \
132 case DLL_THREAD_ATTACH: \
134 case DLL_THREAD_DETACH: \
136 case DLL_PROCESS_DETACH: \
142 if (MLIsCurrentlyUnloadingLibrary()){ \
143 ML_LIBRARY_USER_DESTROY_CODE \
144 ML_UTILS_NAMESPACE::Runtime::destroyRuntimeTypesOfDll(#LIB_TARGET); \
157 #define ML_INIT_LIBRARY_EXT_3(initMethod, NAMESP, LIB_TARGET) \
159 extern int MLInit(int majorVersion, \
160 int majorCAPIVersion, \
162 extern int MLIsCPPAPILinkCompatible(int majorVersion, \
163 int majorCAPIVersion, \
167 void initMethod##initDll() __attribute__ ((constructor)); \
168 void initMethod##initDll() \
171 static bool initDone = false; \
178 MLInit(ML_MAJOR_VERSION, ML_MAJOR_CAPI_VERSION, ML_CAPI_REVISION); \
181 ML_UTILS_NAMESPACE::Runtime::setRecentlyLoadedDllName(#LIB_TARGET); \
185 MLCheckCPPAPILinkCompatibility(ML_MAJOR_VERSION, \
186 ML_MAJOR_CAPI_VERSION, \
196 NAMESP::initMethod(); \
203 void initMethod##destroyDll() __attribute__ ((destructor)); \
204 void initMethod##destroyDll() \
210 if (MLIsCurrentlyUnloadingLibrary()){ \
211 ML_LIBRARY_USER_DESTROY_CODE \
212 ML_UTILS_NAMESPACE::Runtime::destroyRuntimeTypesOfDll(#LIB_TARGET); \
225 #define ML_INIT_LIBRARY(initMethod) \
226 _ML_INIT_LIBRARY_EXT_HELPER(initMethod, ML_UTILS_NAMESPACE, MEVIS_TARGET)
232 #define ML_INIT_LIBRARY_EXT(initMethod, NAME_SP) \
233 _ML_INIT_LIBRARY_EXT_HELPER(initMethod, NAME_SP, MEVIS_TARGET)
243 #define _ML_INIT_LIBRARY_EXT_HELPER(initMethod, NAME_SP, LIB_TARGET) \
244 ML_INIT_LIBRARY_EXT_2(initMethod, NAME_SP, LIB_TARGET)
250 #ifndef ML_STATIC_BUILD
251 #define ML_INIT_LIBRARY_EXT_2(initMethod, NAME_SP, LIB_TARGET) \
252 ML_INIT_LIBRARY_EXT_3(initMethod, NAME_SP, LIB_TARGET)
254 #define ML_INIT_LIBRARY_EXT_2(initMethod, NAME_SP, LIB_TARGET)