|
Boost : |
From: Carl Daniel (cpdaniel_at_[hidden])
Date: 2002-02-18 14:01:53
From: "bill_kempf" <williamkempf_at_[hidden]>
> --- In boost_at_y..., Beman Dawes <bdawes_at_a...> wrote:
> > At 10:09 AM 2/18/2002, bill_kempf wrote:
> > 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.
>
I'm certain there's no way to detect it in the compiler, since DLLs are a linker concept of which the compiler is mostly
ignorant. It would be possible to add code to detect at /runtime/ that the thread library code was statically linked
into an EXE - perhaps in the constructor of a static object so the check happens early.
The code would be something like this:
HMODULE hExe = GetModuleHandle(0);
MEMORY_BASIC_INFORMATION mbi;
static int dummy;
VirtualQuery( &dummy, &mbi, sizeof(mbi) );
HMODULE hMod = (HMODULE)mbi.AllocationBase;
if (hMod == hExe)
{
// we were statically linked
}
Of course, this wouldn't detect the library being statically linked into a DLL along with other stuff, but would that
matter? (being not that familiar with Boost.Threads, I just don't know).
-cd
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk