Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2005-08-19 06:29:24


Robert Ramey wrote:

>>>While we're at it, I would also like to consider enforcing a rule
>>>that there can be at most one instance of serialization code for a
>>>specific type existing at one time.
>>
>>What do you mean? If there are two DLL defining the same function but
>>with different bodies, that's ODR violation. If they define the same
>>function with the same body, that's no problem.
>
>
> Exactly. But since the code resides in different DLLS which are not visible
> at compiler time, the ODR violaton cannot be detected by either the compiler
> or the linker. Actually I'm not sure what happens when one dynamically
> loads two different DLLS which contain the same function signatures. I
> suppose its implementation dependent.

If by implementation dependent you mean OS dependent, that is correct. In
Windows code called through a dynamically loaded DLL:

1) Must be exported by the DLL
2) Is called using a DLL handle to the particular DLL

ie.

int (*p)(int);
HMODULE h(LOadLibrary("SomeDllName"); // HMODULE is the DLL handle
FARPROC fp(GetProcAddress(h,"SomeFunctionName")); // SomeFunctionName must be
exported
p = reinterpret_cast<p>(fp);
int result(p(n...)); // where n is some integer

As you say, there is no ODR violation because this does not happen at
compile-time but at run-time.


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