|
Boost : |
Subject: [boost] boost threads and linking boost statically into a DLL
From: Carlos Empujon (carlos.empujon_at_[hidden])
Date: 2012-11-13 05:46:36
Recently I had some trouble to linking boost statically into a DLL.
After searching around I found that there has been a discussion on http://boost.2283326.n4.nabble.com/Fwd-Thread-Solution-to-conflict-with-MFC-td3477977.html
However it seems that the patch proposed there (see below) did not make it into the trunk.
Has there been a special reason why this has not been included into the normal distribution?
Cheers,
Carlos
/**
* tss.cpp
*
* This file is intended to correctly build a dll using boost::thread
* It is taken from
*
* http://boost.2283326.n4.nabble.com/Fwd-Thread-Solution-to-conflict-with-MFC-td3477977.html
*
* $Id$
*/
#include <windows.h>
#include <boost/thread/detail/tss_hooks.hpp>
extern "C" BOOL WINAPI RawDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID);
namespace
{
BOOL WINAPI dll_callback(HANDLE h, DWORD dwReason, LPVOID p)
{
#ifdef _DLL
if(!RawDllMain(static_cast<HINSTANCE>(h),dwReason,p))
return false;
#endif // _DLL
switch (dwReason)
{
case DLL_THREAD_DETACH:
boost::on_thread_exit();
break;
case DLL_PROCESS_DETACH:
boost::on_process_exit();
break;
}
return true;
}
}
extern "C"
{
extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID)=&dll_callback;
}
namespace boost
{
void tss_cleanup_implemented()
{}
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk