Boost logo

Boost :

From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-02-18 13:53:10


--- In boost_at_y..., Beman Dawes <bdawes_at_a...> wrote:
> 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.

I'm not sure if there is a way to do this. If there is I'd love to
hear about it. In the mean time, I'm adding a build.html page to the
documentation that will talk about how to build/use the libraries on
the various platforms. Hopefully that will help.

Bill Kempf


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