Boost logo

Boost :

Subject: Re: [boost] Fwd: [Thread] Solution to conflict with MFC?
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2011-04-27 13:38:16

Den 27-04-2011 18:21, Anthony Williams skrev:
> Thorsten Ottosen<thorsten.ottosen_at_[hidden]> writes:
>> Den 27-04-2011 17:13, Anthony Williams skrev:
>>> Thorsten Ottosen<thorsten.ottosen_at_[hidden]> writes:

>> Is there any possibility that the initialization of this pointer
>> in tss_pe.cpp can be made dynamic based on some parameter
>> passed to the code? It would be really cool if we could just say
>> #include<boost/thread.hpp>
>> in the code that needs it. AFAICR, we can have global data in headers
>> as long as it is inside some template.
> For the DLL callback to be called automatically, there must be an extern
> "C" global variable called _pRawDllMain, which must be statically
> initialized to point to the callback function.
> I don't see how you could put that in a header without risking >
> definition errors --- the header that initialized it would have to be
> included exactly once across the whole project. Failure to include it
> anywhere would mean that the init function would not be linked.

I searched the source directory to locate this variable. Is

extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD,LPVOID);

not just a declaration of a variable located somewhere else?

If so, we only need to put the initialization of this variable
in a header.

> I haven't tried it, but I think that if the application defines
> boost::tss_cleanup_implemented() then tss_pe.cpp will not get linked
> from the library, so the DLL callback will not be linked, and the MFC
> one should therefore work. Of course, you will then need to ensure that
> boost::on_thread_exit() is called when every thread exits to avoid
> leaking memory and/or resources.

yeah, that won't work well. Then it's far better to include a seperate
.cpp file.


Boost list run by bdawes at, gregod at, cpdaniel at, john at