Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-02-18 11:09:53


At 10:09 AM 2/18/2002, bill_kempf wrote:

>--- In boost_at_y..., "ajp_m" <a.maclean_at_a...> wrote:
>> A colleague of mine found the problem (many thanks Mike!).
>>
>> I did not compile the thread library as a DLL (silly me!).
>> Consequently, PROCESS_ATTACH in threadmon.cpp was not allocating
>the
>> key!
>>
>> i/e. in this section of code:
>> BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID)
>> {
>> switch (reason)
>> {
>> case DLL_PROCESS_ATTACH:
>> InitializeCriticalSection(&cs);
>> key = TlsAlloc();
>> break;
>> ...
>>
>> Of course this begs the question:
>> Is it possible to modify the code so that if it is not compiled as
>a
>> DLL the code will still function correctly?
>
>The actual build process compiles most of the library as a static
>link library, but the threadmon stuff has to be in a DLL,
>unfortunately. This is a consequence of the Win32 MT design where
>DllMain() is the only mechanism that allows you to cleanup thread
>resources.

Can you put a specific check into the threadmod code to give an #error if
it isn't being compiled as a DLL? Only to apply to appropriate compilers,
of course. Would save a lot of grief, I'd expect.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk